natalina's blog

By natalina, history, 2 years ago, translation, In English

Hello, Codeforces!

On Mar/11/2024 17:35 (Moscow time) Codeforces Round 933 (Div. 3) will start.

You will be offered 7 problems, dedicated to the adventures of a restless mathematician, a programmer and just a funny character named Rudolf and his brother Bernard, and 2 hours 15 minutes to solve them. Problems have expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a rating of 1600 or higher, can register for the round unofficially.

The round will be hosted by rules of educational rounds (extended ICPC). Thus, solutions will be judged on preliminary tests during the round, and after the round, it will be a 12-hour phase of open hacks.

Note that the penalty for the wrong submission in this round is 10 minutes.

Remember that only the trusted participants of the third division will be included in the official standings table. This is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them)

  • do not have a point of 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

Problems have been created and written by: vladmart, Sasha0738, t0rtik, Alexey_Parsh, Mordvin13, daha.002, Vladosiya and natalina.

We would like to thank:

  1. Vladosiya and Gornak40 for coordinating the round.

  2. MikeMirzayanov for Polygon and Codeforces platforms and helping prepare the problems.

  3. step_by_step, ashmelev for red testing.

  4. KseniaShk, ibraevdmitriy for yellow testing.

  5. robotolev, Sochu for purple testing.

  6. dan_dolmatov, JuicyGrape, FBI, AimFar for blue testing.

  7. EsraaTaha, Matrosk1n, suborofu, Alenochka, gas for cyan testing.

  8. bugrova, Toy_mouse, ringku_ for green testing.

Good luck!

UPD: Because of the technical issue (see the post https://mirror.codeforces.com/blog/entry/126654), temporarily the only available C++ compilers are: C++14 (GCC 6-32) and C++17 (GCC 7-32).

UPD2: Editorial is posted.

  • Vote: I like it
  • +188
  • Vote: I do not like it

| Write comment?
»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Auto comment: topic has been updated by natalina (previous revision, new revision, compare).

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Auto comment: topic has been updated by natalina (previous revision, new revision, compare).

»
2 years ago, hide # |
 
Vote: I like it -57 Vote: I do not like it

RAMADAN contest starts 15:35UTC+2. Please

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

do not have a point of 1900 or higher in the rating. So div 2 or div 3 ?

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Auto comment: topic has been updated by natalina (previous revision, new revision, compare).

»
2 years ago, hide # |
Rev. 4  
Vote: I like it 0 Vote: I do not like it

why is there such a big gap (20 days) between 2 contests?? Will more contests be added in between?

UPD: Another contest added

Hopefully more contests gets added up in between.

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

First contest during Ramadan!

I hope the tasks will be interesting

And Good Luck for every parcipicant!

»
2 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Sorry Codeforces, I have to attend night-prayer at that time. so, No contest for me for the next 30 days.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I hope to become specialist after this round.

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

"adventures of a restless mathematician"

Mathforces Incoming. Brace yourselves

»
2 years ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

In the last few days, why Div3 contest has been hosted so frequently than before?

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

exciting to become an Expert!

GL everybody :)))

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I hope to solve as many problems as possible :DD

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope reach pupil after this round

Good luck for everyone !!!!

»
2 years ago, hide # |
 
Vote: I like it -20 Vote: I do not like it

Excited to give this contest on my birthday!!!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Expert please

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I wish this contest i could improve the score ! because i have lose four times till now

»
2 years ago, hide # |
 
Vote: I like it -45 Vote: I do not like it

Problem E is one of the worst problems i have ever read

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +31 Vote: I do not like it

    skill issue

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Problem E is one of the greatest problems i have ever read!

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      But it literally is "Write simple greedy algorithm. Then run it 100 times. Then solve 800 rated problem on the results.". What is so great about it?

      • »
        »
        »
        »
        2 years ago, hide # ^ |
        Rev. 3  
        Vote: I like it +15 Vote: I do not like it

        To me, it is a beautiful combination of dp, deque and prefix sum / sliding window.

        If I say it like you:

        A literally is "Write some bruteforce."

        B literally is "Do some observation. Write some code to implement that."

        C literally is "Check some special substring."

        D literally is "Do some implementation with set."

        F literally is "Do some observation. Write simple binary search."

        G literally is "Too hard for me to solve in the contest."

        Life literally is "Be born. Eat. Sleep. Solve some codeforces contests. Go to the grave."

        Something may be literally is "something easy" to you, but "something meaningful" to others.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E has an unusual distance definition and it has not been presented in the russian version for more than half an hour

»
2 years ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

I spent more time in B than problems E and F due to my stupid mistake.

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    same buddy, I really did stupid mistake on problem B that cost me 1 hr & 5 wrong submission with very high anxiety because of the fear of very big rating drop but thank god I solved it & at the last minute solved E as well that pushed my rank to under 1500 and my rating saved

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      How to do B?

      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it +1 Vote: I do not like it

        You can only subtract values from the 0th element by choosing index 1. Therefore you MUST choose index 1 a[i] times. After that you can treat the value at a position 1 as a new 0 positioned value. Therefore after running for loop every value must by 0, otherwise in is impossible.


        for(int i = 1; i < n-1; ++i){ a[i] -= a[i-1]*2; a[i+1] -= a[i-1]; a[i-1] = 0; }
»
2 years ago, hide # |
 
Vote: I like it -23 Vote: I do not like it

bad B, C, D, E, F, G!!!!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Binary search doesn't work for F ?

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

My private Screencast.. A,B,C,D,E Video Solutions here: https://www.youtube.com/watch?v=hSNp4xnn9lc

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +10 Vote: I do not like it

Screencast with commentary (set video quality to HD to be able to read my code)

»
2 years ago, hide # |
Rev. 2  
Vote: I like it -10 Vote: I do not like it

Problem G is nice.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E seem very hard (at least for me) are there other simple solutions not involving dp with segment tree or sparse table?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone explain the 4th test case in problem D.

Like how is it 2 3 5 and not 1 2 3 5?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

RIP all who got WA on test 2 in F :(

I don't know which case I was missing. Can anyone debug my submission : https://mirror.codeforces.com/contest/1941/submission/250809941

»
2 years ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Got trolled by problem F (2 wrong submissions) because (a[i] + a[i+1]) / 2 overflows int :(

Let this be a lesson to use std::midpoint... (or in Java, a[i] + (a[i+1] - a[i]) / 2)

»
2 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I could only get TLA on test 3 for F, which trick was needed to reduce complexity ? FFT ?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For problem G I made a simple Dijkstra where the cost is determined by the size of a std::set which contains all the colors of the edges I've been through. Does anyone have an idea why it doesn't pass Test 3?

Spoiler
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Excuse me guys, but who can help me find mistake in D?

My answer is different with correct answer in only one number, and I coulnd't find mistake.

Here is my code:

void solve() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> ans;
	int r; char c;
	cin >> r >> c;
	if (c == '0') {
		ans.push_back((x + r)%n + 1);
	} else if (c == '1') {
		int frm = (x-r+n)%n;
		ans.push_back(frm + 1);
	} else if (c == '?') {
		ans.push_back((x + r)%n + 1);
		int frm = (x-r+n)%n;
		ans.push_back(frm + 1);
	}
	for (int i = 0; i < m-1; i ++) {
		cin >> r >> c;
		if (c == '0') {
			for (auto el : ans) {
				el = (el + r)%n + 1;
			}
		} else if (c == '1') {
			for (auto el : ans) {
				int frm = (el-r+n)%n + 1;
				el = frm;
			}
		} else if (c == '?') {
			vector<int> v;
			for (auto el : ans) {
				v.push_back((el + r)%n + 1);
				int frm = (el-r+n)%n + 1;
				v.push_back(frm);
			}
			ans = v;
		}
	}
	set<int> res;
	for (auto i : ans) {
		i --;
		if (i == 0) {
			res.insert(n);
		} else {
			res.insert(i);
		}
	}
	cout << len(res) << nl;
	for (auto i : res) {
		cout << i << " ";
	}
}

I will be very grateful to anyone who offers a helping hand

»
2 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Can anyone give me some insights over the Solution of Problem — F Rudolf and Imbalance

  • »
    »
    2 years ago, hide # ^ |
    Rev. 4  
    Vote: I like it +1 Vote: I do not like it

    Easy explanation for F :

    Firstly, you can binary search over your answer (you can easily observe monotonicity)

    Let's check if $$$X$$$ can be our answer or not.

    $$$-$$$$$$ \gt $$$ If there is no index such that $$$a_{i+1}$$$ $$$-$$$ $$$a_i$$$ $$$ \gt $$$ $$$X$$$, then surely $$$X$$$ can be our answer.

    $$$-$$$$$$ \gt $$$ If there are more than 1 indexes such that $$$a_{i+1}$$$ $$$-$$$ $$$a_i$$$ $$$ \gt $$$ $$$X$$$, clearly $$$X$$$ can't be our answer.

    $$$-$$$$$$ \gt $$$ Else let's say $$$a_{i+1}$$$ $$$-$$$ $$$a_i$$$ $$$ \gt $$$ $$$X$$$ for some $$$i$$$, what should be the complexity of the extra problem?

    Let's say the complexity is $$$C$$$, then $$$C \leq a_i + X$$$ and $$$C \geq a_{i+1} - X$$$. Thus, we have a range $$$[$$$$$$a_{i+1} - X$$$, $$$a_i + X$$$ $$$]$$$.

    Lastly, we need to check if we could make a problem with complexity in the given range, say $$$[$$$ $$$L$$$ , $$$R$$$ $$$]$$$, for that, you can simply iterate over $$$d$$$ or $$$f$$$ and use set kind of data structure for searching a possible answer.

»
2 years ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

Is there anyone ignore the "consecutive" in problem E like me ._.

»
2 years ago, hide # |
Rev. 2  
Vote: I like it -8 Vote: I do not like it

G was a nice problem

Can't help but point out that C has more ACs than B tho..

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Would you please provide a hint regarding your solution to problem G for us mere mortals? Please...

    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      You can create a new graph containing all the nodes and all the colors. On this graph, two nodes have a connecting edge if:

      • One is a node and the other is a colour. Let's call these u and c respectively.

      and

      • There exists an edge on the original graph connected to u and has the color c.

      It's not hard to see that the BFS distance on this new graph is exactly twice the answer :) I don't have a rigorous proof though

      The amount of nodes and edges on this new graph cannot be more than O(n+m) so it will pass in the TL.

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    what is logic for ** Problem G** .

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Can't wait to become Expert!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I couldn't implement it in time, but I just wanted to make sure my strategy is correct for E.

Let row_ans[r] represent the minimum cost for some row. We can use prefix sums to calculate some contiguous row_ans and choose the minimum in O(n-k) time. The minimum will be the answer.

As for calculating row_ans[r], we use dp to calculate the minimum cost from dp[r][c] to dp[r][m]. row_ans[r] = dp[r][1].

Simmply apply dfs over dp[r][c] and check the minimum cost between dp[r][c] and dp[r][c+1], dp[r][c+2], ..., dp[r][c+d+1].

Is there anything more/wrong?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

someone tell the approach of PROBLEM D

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I tried F instead of E as seemed easier but failed on test2.

here's the submission (code is clean)
any help is appreciated.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Why do you use upper_bound instead of lower_bound?

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    What about when cur diff > second max diff ?

    Also op1 and op2 can exceed (int) because a[i] is up to 2e9.

    You can check my code it's the same 250750511.

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      cur diff > second max diff !!! ohho damn, How did I even miss it!!!!

      Thanks for pointing out,

      int is not an issue, you can see on top i have #define int long long :)

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      Man It got accepted, how in the world i didn't notice I calculated second max incorrectly, DAMN!!!! Its suicide for me :(

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

"Note that the penalty for the wrong submission in this round is 10 minutes." Does it mean I can't submit for the next 10 min? or is it anything else?

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You can submit for the next 10 minutes.

    It means that your penalty will be increased by 10 once you submit accepted code for that problem.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is there anyway to solve problem E with memoization? Just curious.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    It was not possible, beause the overall complexity would have been d*n*m. I used a multiset in order to memorize information about the d+1 previous supports sorted in ascending order

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem A — Simple sort and binary search.

Problem B — Note that 1st element can only be modified by operations on element 2. Accordingly iterate over the array, simulate the operations on each, and check the last 2 elements for 0. In any case, element value goes < 0, answer is not possible.

Problem C — Simple substring search. First, count for mapie (requires only 1 operation). Then check for rest of the possiblities (pie, map).

Problem D — Let dp(i,j) represents whether all the m turns result in player j having the ball, if we are at move i and currently player j has the ball. Do a simple recurive dp, and final answer is the count of dp[i][m] == 1 over all i players.

Problem E — For each row, let dp(i) represent the min. cost to place supports, such that we place a support at a[row][j]. dp(i) can be calculated as min j from i-d-1 to i-1. Use segment tree to speed up this calculation. For every row, cost for that is dp(m). Final answer is a subarray of size k with minimum sum, that can be done using simple prefix sums.

»
2 years ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

Guys fft tag for B wtf?

»
2 years ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Admit it, who solved B using fft?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

**Dear Codeforces Community ** Please can anyone tell me why this code give wa on test 2 https://mirror.codeforces.com/contest/1941/submission/250799602

and when i just update the vector size with n+1 and m+1 then it gives me tle on test 6

https://mirror.codeforces.com/contest/1941/submission/250822673

the difference between both the codes is just that instead of using vector of size [n][m] i took [n+1][m+1]??

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    WA -> you are not considering when j == m in you fun TLE -> it's clear n * m * d which in worst case n * m * m

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Someone Please answer this python related question regarding problem D. For the input details about m throws, if I take the input as s = input().split(), dist,dir = int(s[0]),s[1] it gets accepted. But during the contest I took it as s = input().rstrip() ,dist,dir = int(s[0]),s[2] (I thought s[1] is the white space?), it gives WA on test 3. Everything else in both the codes is the same. Why is this the case? Can't believe I did not solve a problem because of this :(

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Because there can be lines like 10 ? or 100 ? depending on the value of $$$n$$$, you need first split the line by a space and then parse $$$r_i$$$.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Similar problems : G and arc061_c

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to write tabulation for the following solution to Problem D: 250808686. How do you approach DP in such scenarios?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Somebody please tell me if there is a penalty for failed hacking attempt here in this contest.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    No, hacking does not affect your score in div3 contests.

»
2 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I strongly believe there is something wrong with the Judge for Problem F. This is tourist's submission for F and this is Valee's for F.

I gave the same input to both on ideone. Valee's output doesn't match with the one from tourist. Line 17 of both submissions doesn't match.

So, I submitted this input to hack Valee's submission. It says unsuccessful hack.

I don't understand if I'm doing anything wrong or if the checker is broken.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    Code has undefined behaviour due to out-of-bound access-

    int lb = upper_bound(c.begin(), c.end(), (v[src]+v[src-1])/2-b[i])-c.begin();
    sl = min(sl, max(abs(v[src-1]-b[i]-c[lb]), abs(v[src]-b[i]-c[lb])));
    

    This should be —

    int lb = upper_bound(c.begin(), c.end(), (v[src]+v[src-1])/2-b[i])-c.begin();
    if(lb!=k)
        sl = min(sl, max(abs(v[src-1]-b[i]-c[lb]), abs(v[src]-b[i]-c[lb])));
    

    Different compilers behave differently when undefined behaviour happens. If it's working on the judge compiler, I doubt you can hack this submission with the compiler used for this submission.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by vladmart (previous revision, new revision, compare).

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Hours and hours trying to solve problem E and the only thing that I discoverd that I'm really bad at dp :))

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +2 Vote: I do not like it

I think there might be an issue with the way codeforces is handling problem B. A lot of people have written solutions which should give a tle and they take forever to run on my local machine. However when i try running hacks here, all hacks fail. In fact there is not a single successful hack in problem B. One such example of a tle solution is https://mirror.codeforces.com/contest/1941/submission/250718192

Please tell me if i am missing something and why none of the hacks give tle on these solutions even though they do on my local machine

»
2 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Ok got it Thanks

»
2 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

When will solutions be published?

»
2 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

The set of tasks is a bit unbalanced, B is more difficult C and D

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I think the greedy strategy in B is difficult to prove. Maybe that's why.

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      There is prove (why it's diffucult?):

      1. We can't do operations on $$$i=1$$$
      2. $$$a_1$$$ can only be reduce doing $$$a_1$$$ times operation on $$$i=2$$$
      3. After that, $$$a_1$$$ is zero and we can't do operations on $$$i=2$$$.
      4. Now, array size is reduce by $$$1$$$, continue this algorithm to $$$i = n - 1$$$
»
2 years ago, hide # |
Rev. 7  
Vote: I like it 0 Vote: I do not like it

Why is this test case of problem 2 a "NO" The array should act like this

[5, 6, 0, 2, 3, 0] to

[0, -4, -5, 2, 3, 0] to

[0, 0, 3, 6, 3, 0] to

[0, 0, 0, 0, 0, 0]

Making the answer YES because you can turn the whole array into Zeros.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    how did you get third array from second array? some values have increased I dont see how it is legal move

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it
    $$$\\ Keep \: in \: mind \: that \: each \: element \: can \: only \: be \: decreased.\\ After \: \left [ 0, -4, -5, 2, 3, 0 \right ], you \: cannot \: go \: to \: \left [ 0, 0, 3, 6, 3, 0 \right ].\\ For \: a_{i}=-4, \: this \: term \: can \: only \: be \: decreased.\\$$$
»
2 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Video Editorial for problem E (Rudolf and K Bridges) : Audio (Hindi)

YOUTUBE EDITORIAL LINK---CLICK here

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

This solution for G naturally came to my mind but my I THOUGHT IT WOULD GIVE TLE. can someone explain why its not getting TLE ? as per my understanding even if the logic is correct , if a node is connected to C different colored edges , this solution would consider that node C times and also once that node would come as minimal it the inner loop will work for E ( no of edges ) times , so according to my understanding worst case should be C * E for minimal output for a single node itself . And it should turn out to be TLE , if you think the time complexity is fine can anyone explain why ?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

This was a great contest! Great job, problem setters and organizers!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can someone explain how this is working in time 250679099

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    C++ should be considered cheating for this :) In Rust its TLE

    • »
      »
      »
      2 years ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      So the problem is with codeforces servers?

      • »
        »
        »
        »
        2 years ago, hide # ^ |
        Rev. 5  
        Vote: I like it 0 Vote: I do not like it

        Here is assembly output of this loop:


        ; for(int i = 1;i<n-1;i++){ cmp rax, 2 jle 414 <_main+0x29d> lea rcx, [8*rax] mov rax, r12 lea rdi, [r12 + rcx - 16] nop ; while(v[i-1] > 0){ mov rdx, qword ptr [rax] test rdx, rdx jle 19 <_main+0x12b> sub qword ptr [rax + 16], rdx ; v[i+1] -=vi_1 ; v[i] -=2; lea rsi, [rdx + rdx] ; vi_1 *= 2 mov qword ptr [rax], 0 ; v[i-1] = 0 sub qword ptr [rax + 8], rsi ; v[i] -= vi_1 add rax, 8 cmp rax, rdi jne -36 <_main+0x110>

        As you can see the inner loop is transformed into 2 SUB commands (one for each element), really cool

      • »
        »
        »
        »
        2 years ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Nope, it's due to compiler optimizations. Apparently the compiler rolls the innermost loop into constant-time operations. Optimizations like this do happen sometimes.

    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      I tried rust -O3, and it generates exactly the same thing:

              test    r8d, r8d
              jle     .LBB0_15
              sub     dword ptr [rbx + 4*rax], r8d
              add     r8d, r8d
              sub     dword ptr [rbx + 4*rax - 4], r8d
              mov     dword ptr [rbx + 4*rax - 8], 0
              jmp     .LBB0_15
      

      Not sure why it's TLE on codeforces

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone explain the solution to E.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Ok.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    // 1<=t<=1e3 1<=k<=n<=100 3<=m<=2e5 1<=d<=m 0<=ai,j<=1e6 ai,1=ai,m=0 sum(n,m)<=2e5
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    const int MAXN=105;
    
    int dp[200001],a[MAXN],hei[200001];
    map<int,int> mp;
    
    signed main(){
    	int t;
    	scanf("%lld",&t);
    	while (t--){
    		int n,m,k,d;
    		scanf("%lld %lld %lld %lld",&n,&m,&k,&d);
    		for (int i=1;i<=n;i++){
    			for (int j=1;j<=m;j++)
    				scanf("%lld",&hei[j]);
    			for (int j=0;j<=m;j++) dp[j]=1e17;
    			mp.clear();
    			dp[1]=1;
    			mp[1]++;
    			for (int j=2;j<=m;j++){
    				dp[j]=mp.begin()->first+hei[j]+1;
    				mp[dp[j]]++;
    				if (j-d-1>=1){
    					mp[dp[j-d-1]]--;
    					if (mp[dp[j-d-1]]==0)
    						mp.erase(mp.lower_bound(dp[j-d-1]));
    				}
    			}
    			// for (int j=2;j<=m;j++)
    			// 	printf("%lld ",dp[j]);
    			// printf("\n");
    			a[i]=dp[m];
    		}
    		int ans=0,sum=0;
    		for (int i=1;i<=k;i++)
    			sum+=a[i];
    		ans=sum;
    		for (int i=2;i+k-1<=n;i++){
    			sum-=a[i-1];
    			sum+=a[i+k-1];
    			ans=min(ans,sum);
    		}
    		printf("%lld\n",ans);
    	}
    
    	return 0;
    }
    
    
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why I've Rated compete but it didn't Rated?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In final scoring of this contest , i have penalty of 125 . how is this calculated ? can someone explain me this.

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    it's the ICPC rules. The total penalty is the sum of the time you spent on your solved problems, which is 13+112(1:52)=125

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Now since hacking phase is finished, then can someone tell me why this code is not a tle 250786266?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can anyone give me explanation over the Solution of Problem — G. Rudolf and Subway

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Just build a graph with extra nodes for each color and find shortest path.

    Edit: You can see this for reference.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

So many solutions of G hacked.

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hopefully I'm not the only one doing 0-1 BFS on G ._.

Submitted right after system test initiation so I guess it passed, but I don't trust my messy codes....

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    how do you apply 0-1 BFS on G ??

    • »
      »
      »
      2 years ago, hide # ^ |
      Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      (A bit complex though, I tend to overthink stuff.)

      Re-map the entire graph: each vertex of the new graph has the form of $$$(v, c)$$$, with $$$v$$$ is the original vertex, and $$$c$$$ is the color. This is for maintaining the current color in the trip.

      Edge $$$(u, v, c)$$$ in original graph becomes $$$((u, c), (v, c))$$$, and has weight $$$0$$$ (color doesn't changed — if wanna switch, see below).

      For an original vertex $$$v$$$, all vertices $$$(v, i)$$$ are connected to each other through weight-$$$1$$$ edges (acting as interlude steps if wanting to use an edge of new color).

      From here, the core idea for 0-1 BFS is complete.

      Answer will be $$$min \space dist((b, i), (e, j)) + 1$$$ (the $$$dist$$$ denotes the number of color changes, so add $$$1$$$ for the first color).

      If $$$b = e$$$, answer = $$$0$$$ — this case should be trivially handled first.

      A few touches are required:

      • We only considered vertices appearing at least once in the graph, instead of all vertex + color combinations (coz it can go up to $$$4 \cdot 10^{10}$$$). C++'s STL map (or any BST-based map-like data structure) can help with that.
      • To prevent repeated traversals of weight-1 edges, a special visited check is required for each vertex family (i.e. vertices originated from the same original node, differing only in colors).

      My code, for references (but as warned, it was way more than messy): 250907436

      A bit of code explanations and quirks
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Is this contest rated? No rating changes till now?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My rating is 1655 but i'm still a specialist . WHY ?

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Minor UI glitch post rating change. https://imgur.com/a/mw2YwLz

»
2 years ago, hide # |
 
Vote: I like it -13 Vote: I do not like it

Hello MikeMirzayanov, I received a message saying my solution to 1941E - Rudolf and k Bridges submission 250807913 and singhsoojal solution 250811342 to the problem are quite the same. And thus, we both have been disqualified.

Both Solutions might be very close, but we don't share the same exact code. I didn't share my solution anywhere. We also don't know each others, so we don't have any way to communication.

I think it's unfair to accuse people for cheating just for thinking in the same way and writing codes that are similar but not the same.

Your efforts for making the checker of copying are appreciated but I just figured out it needs some more work.

Thanks for the great round and problems!

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Your solution 250774158 for the problem 1941F significantly coincides with solutions harshsharma2024/250774158, TLExceeded/250796278, codingishard8/250800925, Fusu/250810532, 2.16/250811985.

Here is my code : Accepted after getting wrong answer with this code : Wrong answer and after 3 minutes from getting the wrong answer. I swear that I didn't cheat in the contest, and all the codes in this contest were written by only me and I didn't use any online IDE.

And I didn't like this Plagiarism Mistake at all, not fair facing like these obstacles to get a new rate, specially when I am too close to the new rate.

MikeMirzayanov I've compared the two solution and I think the similarity between them is normal and many user could do such a solution.

»
2 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Its very funny because a problem from the County Phase of the OI in Romania was similar to the G in this round, and it helped me a lot upsolving this round in the week prior to the contest!

Anyway, interesting problems and round!