salyg1n's blog

By salyg1n, 15 months ago, translation, In English

Hello, Codeforces! 🤯

green_gold_dog, ace5, bashkort and I salyg1n are pleased to invite you to participate in Codeforces Round 897 (Div. 2), which will take place on Monday, September 11, 2023 in 17:35.

This round will be rated for participants whose rating is below 2100.

You will be given 6 tasks and 2 hours to solve them. We recommend reading all the tasks. Interactive tasks may occur in the round, so we suggest reading this post.

We want to thank:

We hope you'll enjoy our problems! Good luck!

UPD. Score distribution: $$$500 - 1000 - 1250 - 2000 - (2000 + 1000) - 4000$$$.

UPD2. Congratulations to the winners!

Div. 2

  1. candidatecandidatemaster

  2. Coreopsis

  3. iFFT

  4. Dorothy__

  5. wk______tzc

Div. 1

  1. Golovanov399

  2. Geothermal

  3. arvindf232

  4. Rubikun

  5. Vercingetorix

UPD3. Editorial.

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

| Write comment?
»
15 months ago, # |
  Vote: I like it -10 Vote: I do not like it

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

»
15 months ago, # |
  Vote: I like it +35 Vote: I do not like it

Finally ez rating

»
15 months ago, # |
  Vote: I like it -210 Vote: I do not like it

As a tester, I ask to downvote this comment instead of round announcement

  • »
    »
    15 months ago, # ^ |
      Vote: I like it -20 Vote: I do not like it

    i downvoted both , problem C gave tle on pretest 4 and same logic passed in c++

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +53 Vote: I do not like it

      Yeah, I totally agree. You shouldn't give instructions on how to output in Java for a problem that's impossible to solve in Java if someone follows those instructions.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Problem C seemed so simple yet turned out to be the most painful one. Just wouldnt work with Java

»
15 months ago, # |
  Vote: I like it -45 Vote: I do not like it

Negative contribution :)

»
15 months ago, # |
  Vote: I like it +16 Vote: I do not like it

The hidden texts are cute :)

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

waiting for the challenge ......

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

omg, two contests in two days!

Good luck everyone!

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

score distribution?

  • »
    »
    15 months ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it

    It will published later on...btw it is mentioned above...

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I’ve seen that, but I think it’s a little bit too late and also I want to determine whether to participate in this contest earlier.

»
15 months ago, # |
Rev. 3   Vote: I like it -8 Vote: I do not like it

good contest!

»
15 months ago, # |
  Vote: I like it +12 Vote: I do not like it

Hopefully I reach closer to cm

»
15 months ago, # |
  Vote: I like it +6 Vote: I do not like it

Given my past results in Division 2., I am hopeful that I can reach newbie rank again.

»
15 months ago, # |
  Vote: I like it -11 Vote: I do not like it

As a tester, I will write this round from my second acc 😈

»
15 months ago, # |
  Vote: I like it -8 Vote: I do not like it

That cliff 1250-2000 :(

»
15 months ago, # |
  Vote: I like it -10 Vote: I do not like it

Score distribution gives speedforces vibes.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

:((

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

MikeMirzayanov can you please check your inbox?

»
15 months ago, # |
  Vote: I like it -11 Vote: I do not like it

so why the announcement is "P(G) is't a set" but not "P(G) isn't a set"
what does is't mean,,

»
15 months ago, # |
  Vote: I like it +5 Vote: I do not like it

too interactive contest

»
15 months ago, # |
  Vote: I like it -6 Vote: I do not like it

In my opinion problem C has an issue, if there are already $$$2*N+1$$$ queries, why am I not allowed to go to next case myself? Instead I have to input -1 to jump to next case. Why? Because of this, I had a big penalty.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    got runtime error 2 times because of this

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +24 Vote: I do not like it

    This ruined my contest. Literally i got 4 runtime errors on pretest 2 for this reason. In the question it was mentioned if 2*n+1 moves are done then the game finishes. Also there were no pretests that had 2*n+1 moves to make it more clearer.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      +1

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      The same thing happened with me, got multiple runtime errors and couldn't fix it until the contest got finished. Ruined the whole focus on the other problems.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it -10 Vote: I do not like it

      https://mirror.codeforces.com/contest/1867/submission/223010304 I guess it does terminate after 2*n + 1 moves . Can you check in this submission ?

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Firstly you are doing one operation outside the loop and then for each iteration in loop you are doing 2 operations and the loop runs for 2n+1 times resulting in 1+2*(2n+1) operations that is more than the required 2n+2 I/O operations needed

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Same here.

  • »
    »
    15 months ago, # ^ |
    Rev. 2   Vote: I like it -42 Vote: I do not like it

    salyg1n, green_gold_dog, ace5, bashkort. Isn't it a mistake on author's part? If so, can we manually set my current AC time to my first attempt in problem C? (As it would've been AC in first attempt without this issue)

  • »
    »
    15 months ago, # ^ |
      Vote: I like it -30 Vote: I do not like it

    Exactly spent 1.5 hr while submitting the same code as I can’t notice any error. The round should be unrated.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    +1

»
15 months ago, # |
  Vote: I like it +9 Vote: I do not like it

Hopefully my 2.9s Python submission for C doesn't TLE

»
15 months ago, # |
  Vote: I like it +9 Vote: I do not like it

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Why the java language can't pass the C question, but the C++ language passes. Experience the worst race, hopefully not counting the rankings

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Same thing here. I first tried submitting various java solutions only to get TLE. Same logic in C++ passed in first go.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Sounds like a skill issue to me.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Same issue.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My best guess is for test like #4 where T = 100000, the system judge does not generate the input data for next test in stdin fast enough after the previous test complete.

    I tried to simulate stdin for 100000 tests each with n = 1 on local machine like below. It measured 185 msec. So the fact that test #4 always TLE in system tests suggest some kind of delay introduced by system test for Java submissions.

      static void simulateLargeNumOfTests() {
        long t0 = System.currentTimeMillis();
        {
          // Prepare stdin for 100000 tests each with n = 1 and mex 0.
          // In such case, an immediate -1 will follow after the input of each test.
          int T = 100000;
          StringBuilder sb = new StringBuilder();
          sb.append(T);
          sb.append('\n');
          for (int t = 1; t <= T; t++) {
            sb.append(1);
            sb.append('\n');
            sb.append(1 + RAND.nextInt(1000000000));
            sb.append('\n');
            sb.append(-1);
            sb.append('\n');
          }
          byte[] data = sb.toString().getBytes();
          InputStream fakeIn = new ByteArrayInputStream(data);
          System.setIn(fakeIn);
        }
    
        {
          MyScanner in = new MyScanner(true);
          int T = in.nextInt();
          OutputStream out = new BufferedOutputStream(System.out);
          for (int t = 1; t <= T; t++) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
              a[i] = in.nextInt();
            }
            solve(a, in, null, out);
          }
        }
        System.out.format("%d msec\n", System.currentTimeMillis() - t0);
        System.exit(0);
      }
    
  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    After using a hack to workaround test #4 which always TLE in System Verdict, this submission https://mirror.codeforces.com/contest/1867/submission/223000398 is Accepted with runtime 1949 msec on test #6 where the input array has length 100000 and MEX 100000. It is unclear exactly how many IO interactions in test #6 as it depends on how greedily the Judge choose y each time.

    Overall, the interactive IOs delays of problem C is too much for the given limit of T and timeout, and the problem is partially to do with the System Test. Problem C should either use a smaller limit like 10000 for T or a bigger timeout so to accept legit Java solutions without losing any generality of the problem.

»
15 months ago, # |
  Vote: I like it +71 Vote: I do not like it

I think a lot of people got stuck on E since n odd and k even has no solution, until they realize that n and k are both even, and the problem becomes completely trivial. Not a great problem imo.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    same I almost wasted 30 minutes about thinking it and then I reread the question did it in 5 minutes and then went for e2 made the logic but guess what forgot to print ? in making query and didn't make it whole time I was thinking about my solution but the error was in my code :(

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    Completely ruined my contest. But it's my fault, I missed "Even".

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

    what???i completely didn't realize n and k are both even even at this time!!! sad about this...

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I don't know the completely trivial solution :(

    Can you explain it?

»
15 months ago, # |
  Vote: I like it +62 Vote: I do not like it

The problem E2 is such a good joke.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How to progress from solution for E1 to E2?

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Instead of querying all [i-k+1, i] for the remaining n%k, you can just query half of it first then the remaining half using only 51 queries.

»
15 months ago, # |
  Vote: I like it +34 Vote: I do not like it

Why problem C is unsolvable in java , even java legends like SecondThread and profchi used c++ for this problem.

if it's div2 E , F , then it can be beared but atleast div2 problem A B C should be solvable in java. I got 4 unnecessary penalties.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Never gonna attempt a contest with interactive problems again.

»
15 months ago, # |
  Vote: I like it +7 Vote: I do not like it

Problem E is kinda easy, right?

»
15 months ago, # |
  Vote: I like it +18 Vote: I do not like it

queueforces and I hate interactive problems

»
15 months ago, # |
  Vote: I like it +33 Vote: I do not like it

A: Arrange b[i] by the reverse order of a[i] so the value of {a[i]-b[i]} will be pairwise distinct.

B: For every pair of symmetrical positions i and j, if s[i]==s[j] then we can let l[i]==l[j]==0 or 1 (make 0 or 2 occurences of '1' in t), if s[i]!=s[j] we need let l[i]!=l[j] (make 1 occurence of '1' in t). If n is odd, we can let l[(n+1)/2]==0 or 1 (make 0 or 1 occurences of '1' in t). Let the number of first kind of pair is a, and second kind of pair is b, the answer is b+2*k (0<=k<=a) if n is even, and b+k (0<=k<=2*a+1) if n is odd.

C: In the first move alice choose x=MEX(S) (the initial MEX of S), and in after moves alice always add the number removed by Bob back, then the final value will be the second MEX of initial S. This is the optimal strategy.

D: If k==1, we can only make b[i]=i. If k>=2, we build a functional grpah from b (a graph with n nodes and add edges (i-->b[i]) for 1<=i<=n), and we only need to check if the size of every cycles in this graph is k.

E2: If n%k==0 we can query for n/k segments of length k. Otherwise, observe that if we let r=n%k and make such queries: query(1), query(1+r/2), query(1+r), we can get the xor sum of segment [1, k+r]. Then we can query for floor(n/k)-1 segments of length k for the remained part.

F: I've tried for random approach but got WA on testcase 24.

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

    problem D : if a linear chain of size > k is connected to a k length cycle then how is possible to generate a pattern to get array B?

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

      We can just build it in parts:

      Let $$$n = 5$$$, $$$k = 2$$$, $$$b = [2, 1, 2, 3, 4]$$$

      Graph

      Operations:

      • $$$l = [5, 4] \Rightarrow a = [0, 0, 0, 5, 4]$$$
      • $$$l = [4, 3] \Rightarrow a = [0, 0, 4, 3, 4]$$$
      • $$$l = [3, 2] \Rightarrow a = [0, 3, 2, 3, 4]$$$
      • $$$l = [2, 1] \Rightarrow a = [2, 1, 2, 3, 4]$$$

      Can you see how this can be generalised?

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Start from the beginning of the chain and set first $$$k-1$$$ elements. Continue until you reach the cycle, then set the cycle

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +13 Vote: I do not like it
    Diagram for E
  • »
    »
    15 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Actually, I think quite easy to kill random approaches for F, one can just construct a tree with all possible subtrees of size k except for 1 which random will find it hard to find.

»
15 months ago, # |
  Vote: I like it +106 Vote: I do not like it

I see now that you have n and k as even integers in the interaction section. But why not mention that in the initial problem statement?

The $$$n \leq k^2 \leq 2500$$$ was weird as well. Also that has to be one of the easiest D2E ever once you notice all that.

  • »
    »
    15 months ago, # ^ |
    Rev. 2   Vote: I like it +11 Vote: I do not like it

    Ackchyually, you must know that $$$n$$$ and $$$k$$$ would be even, when the problem is E1.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

      I saw that the numbers are even only after reading this comment. It's my own fault, and it's stupid to think about it now, but most likely I would have passed this task if I had seen it.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      lol this comment deserves most likes!

»
15 months ago, # |
Rev. 2   Vote: I like it -11 Vote: I do not like it

Why bitwise operator in easy problems (such as A, B) again?

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Where do you see bitwise operator that much. Xor in binary strings = flipping i-th digit. Problem A isn't about bitwise at all

»
15 months ago, # |
  Vote: I like it +9 Vote: I do not like it

Is it just me or problem E1 is actually easier than B and C :D

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Wait really? I didn't even see, I wasted up my time trying D :/

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Why is the C problem so TLE-constrained for python……

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    For Java as well

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I use python and got TLE on problem B testcase 11, problem C testcase 4 with default input() method during the contest. But after adding

    import sys 
    input=sys.stdin.buffer.readline
    

    They all passed the test.

    A really frustrated experience for me though.

»
15 months ago, # |
  Vote: I like it -15 Vote: I do not like it

The game ends when Bob cannot make a move or after 2⋅n+1 moves so why did i need to take another input after completing the 2*n+1 moves which resulted in me getting 4 runtime errors

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Yeah, that was very confusing

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +80 Vote: I do not like it

    I don't think there was any ambiguity in the problem statement. The interaction guide says that after you output $$$x$$$, you should read an integer $$$y$$$. It never says that you should read $$$y$$$ only if the game is not already over or that you should read $$$y$$$ only if Bob is making a move: every time you output an $$$x$$$, you need to read a $$$y$$$.

    It's particularly easy to get tripped up on interactive problems by making incorrect assumptions about the I/O format, which is why you should always read the interaction section of the statement carefully before beginning to implement your solution.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Whenever i encounter an interactive problem in the future this contest would remind me to read the I/O format completely before attempting it. Thnx

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It was not clear enough, since it was mentioned in the problem statement that after 2n+1 moves, the last move would be of Alice's.

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it +17 Vote: I do not like it

        "To make a move, output an integer $$$x$$$ ($$$0 \le x \le 10^9$$$) — the number you want to add to the set $$$S$$$. $$$S$$$ must not contain $$$x$$$ at the time of the move. Then, read one integer $$$y$$$ ($$$−2 \le y \le 10^9$$$)."

        What about this is not clear? Remember that for implementation details, you should always trust the Interaction section instead of assumptions based on the statement of the problem.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I'm not complaining, as I didn't solve the problem myself, but it kinda is the job of the testers to remove the confusing parts of the problem statement, and personally, I feel like that is something they should have pointed out so it could've been edited.

»
15 months ago, # |
  Vote: I like it +4 Vote: I do not like it

I am ecstatic about solving 1 problem in just 40 minutes this time. Huge improvement from the last contest where I spent 1+ hrs on 1 problem.

»
15 months ago, # |
  Vote: I like it +1 Vote: I do not like it

In problem C, the game is supposed to end after 2*n+1 moves right? so when I ran a loop till 2*n+1 it kept giving me Wrong Answer, when I ran a infinite loop it passed. Why is that? Can someone explain? If the game is supposed to end after 2*n+1 moves, then why should I go further and read y=-1 to end the game?

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

    "To make a move, output an integer $$$x$$$ ($$$0 \le x \le 10^9$$$) — the number you want to add to the set $$$S$$$. $$$S$$$ must not contain $$$x$$$ at the time of the move. Then, read one integer $$$y$$$ ($$$−2 \le y \le 10^9$$$)."

    Is it not clear that after every time you output $$$x$$$, you need to read in $$$y$$$?

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In this entire duration i somehow managed to solve A,wt shall i do, i am really getting depressed,i am soo weak, wt do i need to practice in order to be able to be good at cp .

»
15 months ago, # |
  Vote: I like it +2 Vote: I do not like it

RIP Ratings,

Thanks to 1867C - Salyg1n and the MEX Game

»
15 months ago, # |
  Vote: I like it +2 Vote: I do not like it

Thought that the game in C literally ends after $$$2\cdot n + 1$$$ turns, turns out that it was needed to read the -1 from the input (couldln't solve D in time anyway, so w/e).

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

The first three questions are not difficult to distinguish, and the description of question B is too abstract, which is not a language that human beings can understand for me

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I am sure of my approach for C but still giving WA on test 2. Never solved an interactive problem before. I’d appreciate if someone can point out my mistake

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    According your code, I think when Nextmove = n; it will wrong. Like this: n = 2 a[] = 0 1 Step 1: A:2 B:1 Step 2: A:1 B:0 Step 3: A:0 B:-1 -> it need n+1 loops

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      my aproach was fine its just that I didn't take the input for the move after 2n+1

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Just tell me one thing, colors of high grades, in div2 D we just had to find out if k-1 going in a cycle like in union find will end up not visiting the same element again. Was this the answer to it? Like array 2 3 5 3 4 so going like 1 -> 2 -> 3 -> 5 -> 4 -> 3 ...

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Not necessarily, you can do this to k nodes without them being in a cycle, I will explain solution.

    Spoiler
  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I just checked that every path from a non-zero element leads into a cycle of length $$$k$$$.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Lets take the sample test case. n.= 5, k = 3 2 3 5 3 4

      What cycle are you forming of length k can you mark?

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Well it's a functional graph where each node $$$i$$$ has an outward edge to $$$b_i$$$. So there is a cycle $$$3,5,4$$$. and if you start at any other node and keep following the outward edges, you will end up at that cycle, which has length $$$k=3$$$.

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Oh, and if $$$k=1$$$, then each non-zero must point to itself.

»
15 months ago, # |
  Vote: I like it +5 Vote: I do not like it

Great round, thanks a lot for making the interactive problem not the hardest one, this is the first time I was able to solve one and it made my day!

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice problems, I only wonder why couldn't you write simple and clear limitations in E, for me they were confusing and unclear tbh.

»
15 months ago, # |
  Vote: I like it +7 Vote: I do not like it

E1 was so easy but i did x-- instead of x++ in a while loop and couldn't debug in 20 minutes.So disappointed .

»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Can't see any passing Java solution for Problem C at all. Did anyone else checked?

»
15 months ago, # |
  Vote: I like it -6 Vote: I do not like it

salyg1n Watch out for the TLE Java submissions of Problem C. Those submissions are very insightful and can easily tell that the problem wasn't properly tested for a language other than C++.

I even tried using fast I/O in Java.

Do something about that, as the same logic is getting passed in C++.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    System.out.println() is every slow so I used c++ for this task. If it was not interactive we can use fast output

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for the awesome contest <3

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

from now whenever i will see Interactive tasks in blog... i will go to bed :(

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Best round ever!!! Thanks a lot!!! Why am i so stupid, that i didn't saw, that in E we have only even $$$n, k$$$... Waste like an hour with odd numbers, but solved for even in 20 minutes... Could have solved D...

Btw, i think you should have written in the statement, that $$$n, k$$$ are even not ONLY in input format... Or at least make a notification about it...

»
15 months ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

I pass the C problem with great difficulty!!!Why python can't pass the C problem????

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

Interactive Forces :)

»
15 months ago, # |
  Vote: I like it +23 Vote: I do not like it
»
15 months ago, # |
  Vote: I like it +6 Vote: I do not like it

I don't know how many dislikes this will get but, is it normal if you start problem D when 1 hour 10 minutes is left and still not able to fully come up with a solution which has a logical background. Even if after 10 minutes my intuition said something to do with graph cycles, I was not able to come up with a logical solution to base my intuition. Does it happen to everyone and how you fix it? Doing more problems doesn't logically seems correct for solving problem D or is it? :')

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    I accidentally understood the proof of solution by YocyCraft while answering one of the comments, but I couldn't solve it myself. I guess practise makes perfect. At least you got the idea to use functional graphs

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Knowing properties of successor (functional) graphs may help, more specifically that in each component of a successor graph there is one and only one cycle (I completely forgot about that one during the contest).

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I loved problem D but I couldn't even think that it's graph and cycles xD, please anyone suggest to me good problems similar to this D.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It only takes a few simulations of the operation on the sketchpad to discover the cyclic.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

can anyone tell approaches of problem 2 xor palindrome

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Hints:

    Consider the indices $$$i=1,2,\dots,\big\lfloor\frac{N}{2}\big\rfloor$$$.

    If $$$s_i=s_{n+1-i}$$$, then we must use either $$$0$$$ or $$$2$$$ ones at these indices.

    If $$$s_i\ne s_{n+1-i}$$$, then we must use exactly $$$1$$$ one to flip one of these two bits.

    Furthermore, if $$$N$$$ is odd, then we can flip the bit in the middle if we want to.

    Solution
»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone pls tell why my C failed on system testing?

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

why this code by java get TLE ? 222937329 but this code by c++ get AC 222942899

They are exactly the same code

MikeMirzayanov

  • »
    »
    15 months ago, # ^ |
      Vote: I like it -17 Vote: I do not like it

    Because C++ > Java

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Not fair every code pass with c++ should pass by java

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it +14 Vote: I do not like it

        Where do rules say so?

        • »
          »
          »
          »
          »
          15 months ago, # ^ |
            Vote: I like it -19 Vote: I do not like it

          If it's fair Why Codeforces allow to use different languages One get ac because he know c++ And another one get tle because he write java?? The competition is for those who can solve the problems using any language allowed by the site

          • »
            »
            »
            »
            »
            »
            15 months ago, # ^ |
              Vote: I like it +10 Vote: I do not like it

            Well it's known that python is ~100 times slower than C++ and Java, yet it's allowed to use in competition. However a lot of problems can't be solved on python. Same with Java. I guess C++ is the best language for olympiad programming, that's why people use it and problems are made for C++ and MAYBE you can pass using other languages, but no one guarantees you that

            P. S. I don't know for sure, but maybe there are IO optimisations in Java which can make your solution pass

      • »
        »
        »
        »
        15 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Unfortunately that's not true.

        Our target is to get an accepted code within the given time and memory limit. It doesn't matter which language we use. If we use a slower language it is not their fault.

        The time limit and constraints are decided by the problem setter. In some problems, the setter wanted to allow some complexity and not allow slightly greater one. In these cases, they won't care about different/slower languages.

        Find a language faster than C++, it will become mainstream and they'll stop worrying about C++ time limits.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it -19 Vote: I do not like it

    UnfairForces

  • »
    »
    15 months ago, # ^ |
      Vote: I like it -25 Vote: I do not like it
  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
  • »
    »
    15 months ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Problem C has either too big T or too tight time limit. For example, it could have a limit of T like 10000 instead of 100000. As a result, the problem would be more effective to accept Java solution with the right idea and algorithm. The way it is requires low level IO hacks to squeeze the last IO efficiency to possibly and barely meet the time limit, and as a result the IO code is messy and has poor readability etc, which is NOT the purpose no should be the focus of the problem.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The problem C said, The game ends when Bob cannot make a move or after 2*n+1 moves (in which case Alice's move will be the last one).

This code got the wrong answer during the contest as I wrote code according to the 2*n+1 move.

And after the contest, this one gets ac as I write code according to 2*n+2 move. Why does this happen?

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    IMHO:

    2*n+1 is Alice's last move, after this Bob replies with -1 (which goes to your "n" in the outer loop).

    2*n+2 reads "-1" and moves to the next test case.

»
15 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

E2 can be done in maximum of 51 queries ,right? Why is the constraint 57 then?

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Because author studies in 57th school

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The constraint does not have to be at the tight lower bound. 51 might serve as a big hint; author might have other legit ideas to solve the problem etc.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    did you find that there're a lot of 57 in the problem set?

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

My O(n) code for B got rejected in PyPy but got accepted in python, same exact code . Look into my submissions: https://mirror.codeforces.com/submissions/jagan028

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It seems PyPy struggles more with IO: 223000606

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    alwayss use FAST I/O with python , add this to your code and it will get AC :

    import sys

    input = lambda: sys.stdin.buffer.readline().decode().rstrip()

    t = int(input()) .........

  • »
    »
    15 months ago, # ^ |
    Rev. 3   Vote: I like it +5 Vote: I do not like it

    Your code currently spend most time reading in data. What you need is a faster input:

    import sys

    input = sys.stdin.readline

    This is a must for all python/pypy coders, otherwise you will TLE a lot. Just copy the faster input into your template.

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Back to back IND vs pak match and back to back contests

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Worst Cf round ever encountered. No announcements made during the ongoing contest to clarify various confusions in the statement.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Feels like C was forcefully made an interactive problem.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

bruh

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

is it just me or E1 and E2 are very easy??

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Dammn Bro, A Big Yes, in fact after solving E1, E2 was kinda obvious. I should have attempted these questions 1st before D :(

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

constructive algorithms x7

»
15 months ago, # |
  Vote: I like it +34 Vote: I do not like it

Just upsolved E1 and E2, they both seem much much easier than the normal E of Div2, Anyone else who thinks the same?

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

    Yeah it was very easy to observe and implement.I wasted all my time trying to solve D.It took me just 15 minutes to solve E after contest without any hint.Regret XD

»
15 months ago, # |
Rev. 3   Vote: I like it +8 Vote: I do not like it

MikeMirzayanov salyg1n geranazavr555

I registered to this contest when I was 2100+, so I was labeled as out of competition. The rating is not updated for me. Can you fix this?

»
15 months ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

Maybe problem E2 is a bit easier than D?

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

i'm wondering why my solution to div2 d cannot pass the pretest#2 on the 568th input.

my solution:

  1. add edges: from i to b[i]

  2. check if every i is in a loop case: i is in a loop if the length of the loop is not k, "no" case: i is not in a loop

update: i know.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone explain how can't a be converted to b in examples test case 2 of b=[2,4,3,1] ,,,, using a=[3] and then a=[1,2,4] ? fk this shit.

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

.

»
15 months ago, # |
  Vote: I like it +15 Vote: I do not like it

Video Editorial for A — E2 I hope it will Helpful for Newbies and Pupils ... LINK TO YOUTUBE

»
15 months ago, # |
Rev. 2   Vote: I like it -35 Vote: I do not like it

green_gold_dog ace5 bashkort salyg1n

screw this contest!! who the hell wrote the C problem ?!! the game ends after 2*n+1 MOVES so why do I have to take the input after n+1 moves for ALICE ???!!!! i hope the author starts learning simple ENGLISH !! ruined the whole contest for me !

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    pls read "interaction protocol" again: "To make a move, output an integer x — the number you want to add to the set. Then, read one integer y"

»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

wheres the editorial?

»
15 months ago, # |
  Vote: I like it +11 Vote: I do not like it

So, no editorial for this contest?

»
15 months ago, # |
  Vote: I like it +9 Vote: I do not like it

When will editorial be out?

»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

RIP editorials

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anybody give some hints for F?

»
15 months ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

I feel that the order of E needs to be swapped with D, both in terms of the difficulty of thinking about it and the difficulty of implementing it in code. I just started writing E after the contest, and realized that the difficulty of thinking about E is really not too high.

You can find this gap in the two codes I submitted: E2 D

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In problems C, I try to use the scan rather than cin to get the output of Bob. But I get the Idleness limit exceeded :) Can someone tell me why can't use scan?

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it's not about the input, you have to do output correctly (fflush(stdout) for printf or cout << std::flush/cout << std::endl for cout)

»
15 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Interesting problems! I love it!!!

»
15 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

div2D. how to prove that if there is a cycle of length x!=k, then the answer is NO? thanks in advance

ps: actually, that's not the main question. i just can't find mistake in my thoughts: it's obviously that we must have at least one cycle of length k. also, for every V that is not in cycle, we can place it to the right place using vertices that lie in cycle of length k. now consider vertices that are in cycle of length x!=k. for such vertices we can cut cycle by some edge and add some fake vertices and edges (that will fill the space for vertices that are in cycle of length k, because the last move is operation with cycle of length k and we don't care about such 'fake' numbers) so that our new cycle has length k or 2*k. thus the necessary and sufficient is just to have at least one cycle of length k. where am i wrong?

pps: nvm got it thanks <3

  • »
    »
    15 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Whenever you do a single "move", you write a cycle of length k into the array. Later, you can overwrite parts of that cycle with another cycle of length k. However, that doesn't allow you to create a cycle of length!=k, because if you overwrite any part of the old cycle then the old cycle is simply broken, it can't become a cycle of different length.

»
15 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

E2 can be actually done in 51(49+2) operations instead of 57.

If n=2500 and k=50, then it takes n/k=50 operations.

Otherwise, my submission E2 handles something like n=2498 and k=50 in 51=49+2 operations.

  • »
    »
    15 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    BTW, you should maybe modify your comment. I read this as 51*(49+2) operations.

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I meant 51 expressed as 49+2 and not 51*(49+2). Sorry, for the confusion.

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Why so few div2 contests this month? I can see only 2 div2 on calender for this month.

»
15 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Nice problems imo!

I liked that they had cute solutions with short implementations, and the proof difficulty is very appropriate.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I want to clarify that my solution matched with some one according to system but I don't think except the template anything has matched. Your solution 222949914 for the problem 1867C significantly coincides with solutions subodh.r/222945531, Mr.Roamer/222949914. This are the 2 solutions. And the template we both used is available here https://youtu.be/8ymiMHQPgZY Pls review the solutions if possible. I apologise for the delay in doing this comment.__