salyg1n's blog

By salyg1n, 8 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

»
8 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).

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

Finally ez rating

»
8 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

  • »
    »
    8 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++

    • »
      »
      »
      8 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.

  • »
    »
    8 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

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

Negative contribution :)

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

i hope you learnt from round 893

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

The hidden texts are cute :)

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

waiting for the challenge ......

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

After round 896 div 2, I hope this makes me feel better about myself again. I'm looking forward to it :') Good luck everyone!

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

omg, two contests in two days!

Good luck everyone!

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

After round 896 div 2, I hope this makes me feel better about myself again.

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

score distribution?

  • »
    »
    8 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...

    • »
      »
      »
      8 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.

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

good contest!

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

Hopefully I reach closer to cm

»
8 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.

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

ryskmax for being the only blue tester and giving valuable feedback. 🐳

Fair and equal testing moment.

»
8 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 😈

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

That cliff 1250-2000 :(

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

Score distribution gives speedforces vibes.

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

:((

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

MikeMirzayanov can you please check your inbox?

»
8 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,,

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

too interactive contest

»
8 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.

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

    got runtime error 2 times because of this

  • »
    »
    8 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.

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

      +1

    • »
      »
      »
      8 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.

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

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

      • »
        »
        »
        »
        8 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

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

    Same here.

  • »
    »
    8 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)

  • »
    »
    8 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.

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

    +1

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

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

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

»
8 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

  • »
    »
    8 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.

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

    Sounds like a skill issue to me.

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

    Same issue.

  • »
    »
    8 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);
      }
    
  • »
    »
    8 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://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.

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

Problem C really pulled an UNO reverse card on me. I thought the solution wouldn't be the one I was thinking but it turned out it was.

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

    Same for me. But at the end when I was done with coding, and I was trying some random cases and suddenly it hit me that this should be the accepted solution.

»
8 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.

  • »
    »
    8 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 :(

  • »
    »
    8 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".

  • »
    »
    8 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...

  • »
    »
    8 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?

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

The problem E2 is such a good joke.

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

    How to progress from solution for E1 to E2?

    • »
      »
      »
      8 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.

»
8 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.

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

Never gonna attempt a contest with interactive problems again.

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

Problem E is kinda easy, right?

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

queueforces and I hate interactive problems

»
8 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.

  • »
    »
    8 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?

    • »
      »
      »
      8 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?

    • »
      »
      »
      8 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

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +13 Vote: I do not like it
    Diagram for E
  • »
    »
    8 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.

»
8 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.

  • »
    »
    8 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.

    • »
      »
      »
      8 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.

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

      lol this comment deserves most likes!

»
8 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?

  • »
    »
    8 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

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

      Alright thanks, but I mention the last A div 2 problem is xor

»
8 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

  • »
    »
    8 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 :/

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

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

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

    For Java as well

  • »
    »
    8 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.

»
8 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

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

    Yeah, that was very confusing

  • »
    »
    8 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.

    • »
      »
      »
      8 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

    • »
      »
      »
      8 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.

      • »
        »
        »
        »
        8 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.

    • »
      »
      »
      8 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.

»
8 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.

»
8 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?

  • »
    »
    8 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$$$?

»
8 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 .

»
8 months ago, # |
  Vote: I like it +2 Vote: I do not like it
»
8 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).

»
8 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

»
8 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

  • »
    »
    8 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

    • »
      »
      »
      8 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

»
8 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 ...

  • »
    »
    8 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
  • »
    »
    8 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$$$.

    • »
      »
      »
      8 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?

      • »
        »
        »
        »
        8 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$$$.

      • »
        »
        »
        »
        8 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.

»
8 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!

»
8 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.

»
8 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 .

»
8 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?

»
8 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++.

  • »
    »
    8 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

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

Thank you for the awesome contest <3

»
8 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 :(

»
8 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...

»
8 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????

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

Interactive Forces :)

»
8 months ago, # |
  Vote: I like it +23 Vote: I do not like it
»
8 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? :')

  • »
    »
    8 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

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

    I did not solve it during contest, but I did after the contest without looking at any hint/solution.

    $$$a_{l_i}$$$ to $$$l_{(i\%k)+1}$$$ looks like a complicated formula, maybe there is some special meaning behind it, so we should try to understand it better. It should be obvious that $$$(i\%k)+1$$$ means the next element, so for thinking's sake let's just assume it is $$$i+1$$$. Then $$$a[l[i]]=l[i+1]$$$ is the code equivalent of the formula. We also have $$$a[l[i+1]]=l[i+2]$$$, and if you substitute back you get $$$a[a[l[i]]]=l[i+2]$$$. Hopefully at this point it looks enough like a linked list and $$$a$$$ represents the next array.

  • »
    »
    8 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).

»
8 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.

  • »
    »
    8 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.

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

can anyone tell approaches of problem 2 xor palindrome

  • »
    »
    8 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
»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
8 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

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

    Because C++ > Java

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

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

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

        Where do rules say so?

        • »
          »
          »
          »
          »
          8 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

          • »
            »
            »
            »
            »
            »
            8 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

      • »
        »
        »
        »
        8 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.

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

    UnfairForces

  • »
    »
    8 months ago, # ^ |
      Vote: I like it -25 Vote: I do not like it
  • »
    »
    8 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
  • »
    »
    8 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.

»
8 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?

  • »
    »
    8 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.

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

      Oops! I missed that thing. I thought the loop had done the job of the move-giving part, but forgot that after ending all the moves, Bob can send -1. That -1 may trigger something to process maybe on the judge-end.

      Thank you for the clarification.

»
8 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?

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

    Because author studies in 57th school

  • »
    »
    8 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.

  • »
    »
    8 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?

»
8 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://codeforces.com/submissions/jagan028

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

    It seems PyPy struggles more with IO: 223000606

  • »
    »
    8 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()) .........

  • »
    »
    8 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.

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

    Thanks for the help guys!

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

I've just solved problem C, got the solution on paper already but didn't implement on time, this is my first time solving interactive problem during the contest.

Thanks guys for the contest!

»
8 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

»
8 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.

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

What is negative contribution?

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

Feels like C was forcefully made an interactive problem.

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

bruh

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

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

  • »
    »
    8 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 :(

    • »
      »
      »
      8 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] ? jai bholenath

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

constructive algorithms x7

»
8 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?

  • »
    »
    8 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

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

Help me explain "Additionally, the number y must be strictly smaller than the last number added by Alice." in problem C div 2 with accepted test case:

1

5

1 2 3 5 7

0

7 7

5 5

-1

why Bob can remove 7 after Alice added 0? thanks everyone.

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

Please tell me what is wrong with this code (Submission for problem C) :- a) https://codeforces.com/contest/1867/submission/222960759

and how it is different from :- b) https://codeforces.com/contest/1867/submission/223030553

a) -> WA b) -> AC

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

How many questions do I need to solve in a Div2 round to reach 1200? I solved 2 this time, that too without penalties and still rating affected negatively :)

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

    You need to solve the question as soon as possible, then you will get a good score. Because with the time marks of a question will decrease.

    Example

    1st case:- If you solve question A in the first 5 minutes and get 490 marks but can not solve any other questions.

    2nd case:- You solve A and B in the last 5 minutes of the contest Then that time you will get approx 200 marks for A and 280 for problem B so your score will be around 480.

    So you will get a good rating in 1st case instead of solving 2 questions in 2nd case.

    Please keep in mind the below points

    1. If your rating is not getting increased don't worry, it is just competitive performance.

    2. Just try to solve more questions in the contest.

    3. The ultimate target is to solve more questions in less time.
»
8 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?

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

Maybe problem E2 is a bit easier than D?

»
8 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.

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

Some one Please help me what wrong with my solution it is showing TLE, this is my first interactive problem.

EDIT: I found the issue it was mistake in logic

https://codeforces.com/contest/1867/submission/223039411

»
8 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.

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

.

»
8 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

»
8 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 !

  • »
    »
    8 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"

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

wheres the editorial?

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

So, no editorial for this contest?

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

wants minus contribution

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

When will editorial be out?

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

RIP editorials

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

Can anybody give some hints for F?

»
8 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

»
8 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?

  • »
    »
    8 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)

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

      that's too weird. The same code just changed the scanf to cin and got the AC. It's my first time to process the problem like this. Next time I will perform better

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

Interesting problems! I love it!!!

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

Waiting for the tutorial

»
8 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

  • »
    »
    8 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.

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

please make good problems from next time

»
8 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.

  • »
    »
    8 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.

    • »
      »
      »
      8 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.

»
8 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.

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

please post the editorial of this contest

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

why am i getting runtime error @testcase3 que D. Any python charmers hlp!


for _ in range(int(input())): n,k=map(int,input().split()) arr = [x - 1 for x in map(int, input().split())] if k==1: if arr==list(range(n)): print('YES') else: print('NO') else: memo={} def dfs(node,c): if node in memo: return memo[node] count[node]=c ch=arr[node] if count[ch] is None: local=dfs(ch,c+1) else: if abs(count[node]-count[ch])+1==k: local=True else: local= False memo[node]=local return local final='YES' for i in range(n): count=[None for _ in range(n)] ans=dfs(i,0) if ans is False: final='NO' break print(final)
»
8 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.

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

@MikeMirzayanov

My old Codeforces ID, Mussic has been blocked by Codeforces.

When I try to log into it, it shows me the message "Disabled by Administrator" due to "significantly coincident" matching of my solution for submission 222923273, 1867A - green_gold_dog, массив и перестановка and 222980969, 1867C - salyg1n и игра с MEX of this contest.

I can swear that I have neither copied any of my solution from anyone, nor shared my own solution with anyone.

The questions was very straight forward and and did have some standard ways of solving, like using storing the pair of vectors. So, the matching was purely coincidental and inevitable.

Kindly remove the restrictions on the Codeforces ID: Mussic, as it contains months of my hardwork.

»
5 days 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.__