Proof_by_QED's blog

By Proof_by_QED, history, 7 months ago, In English

Hello Codeforces.

We are introducing a new type of problem which may appear in future Codeforces rounds, called Communication problems!

In these problems, your program would be ran twice, with different input and output formats between the runs. All variables stored in the memory will be lost between runs. However, the information given to you on the first run may be important to you for completing the second run correctly. Therefore, one of the key challenges in these types of problems would be to find a way to use the limited amount of output you are given in the first run to communicate information to the second run. Below shows a flowchart.


2025-09-06-12-40-07
Flowchart for communication problems

In these problems, time and memory limits for both runs would be kept separately. For example, if a problem has a time limit of $$$2$$$ seconds, you will only get the Time Limit Exceeded if program runs for more than $$$2$$$ seconds on one of the runs, but not if both runs takes $$$1.5$$$ seconds.

It is also possible that a problem is both interactive and run-twice. There may be interaction on either run of your program. For these types of problems, it is especially important to read the problem statement carefully to ensure you are getting the input and interaction format correctly, especially regarding whether you must flush your outputs.

To give participants a feel of these new types of problems, we will hold Testing Round 20 (Unrated, Communication Problems), which will start on Nov/03/2025 17:35 (Moscow time). You will be given $$$1$$$ hour to solve $$$3$$$ run-twice problems. The problems are authored by cry, yse, SpyrosAliv, and chromate00. One problem on the set will be interactive, so you are recommended to read the guide for interactive problems if you are unfamiliar with these types of problems. Of course, this round will be unrated. Good luck, and I hope you will have fun with the new type of problem!

Edit: The contest will be in ICPC format with no pretests and hacks disabled.

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

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

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

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

$$$67$$$

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

Oh no...

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

So now we solve for alice and bob, yaay

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

As Competitive Programmers, we already have communication problems.

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

I'm Excited..

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

As a tester, wait where is the tester list.

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

Any good advice on how to test communication problems locally in a fast and simple manner? Because for interactive problems it's the most painful part despite problems themselves being fun.

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

    It will be better for communication problems than interactive ones. Because you just need to copy the data, run it once, copy the result, then run it again. There is no need to think what should be input like interactive problems.

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

      the input for the 2nd run will be dependent on the output of the 1st run, it doesn't mean it'll be the same. well we'll get to know today

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

        Well, now I know it depends. You are right. It happens to me that there may be even harder situations. XD.

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

    On olympiads the problem author gives an archive file containing a program that will test your code automatically for both interactive and communication problems, and I would definitely like seeing that implemented in codeforces. One can only hope.

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

My crush already ran twice (away from me)

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

This being posted one week after my run-twice problem in PHSCO is a pretty funny coincidence lol

Either way, run-twice is a very under-appreciated problem format in Codeforces and I'm excited for its debut in a future rated round!

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

    Also, will this contest mean that Codeforces will give better debugging feedback for run-twice problems (i.e. sample verdicts)? Because a big issue with run-twice right now is that the only judging information shown is the input during the first run and the output during the second run (first run output and second run input is notably hidden).

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

Will the run-twice problem(s) being announced in contest post like interactives? When will the first rated contest using this new setup of problem?

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

Would this format help combat AI? I think interactive problems are generally harder for chatGPT to figure out (is this true?). If we make interaction non-trivial, we have more potential choke points.

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

    Around half a year ago (probably before o3 and o4-mini) that might have been true. But now, judging from their performance at IOI 2025, I suppose we can't be so sure about it. Similar to interactive problems, the coordinators need not (and probably should not) care about AI when choosing such problems for rounds.

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

      It got the least amount of points on the communication problem. So, it might be correct to say that it performs worse on communication problems relatively to batch problems. And maybe it's due to the fact that #communication_problems << #batch_problems, thus less data for it to train on.

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

        Even 65 points was not easy on that problem. Notice that a plenty of Gold and Silver-winners could not get past 65, let alone 30.

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

        It got the least point on that problem, because that problem is the hardest problem in the contest. Your comparison would make sense if you were comparing batch vs communication of the same difficulty.

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

          by "hardest" you mean, the only problem which was not solved during the contest. Notice that it's not the one with the least average points. I mean, 75 people got more than 65 points, so AI should be able to do that kind of stuff no?

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

      Judging AI by just from their performence in IOI is wrong. Not because AI didn't do that, AI in fact did do that. But what's not being told is that google and microsoft consumed hundreds of thousands of dolars worth of electricity trying to get those scores, and no AI company is going to give access to that to a customer paying 20$ or so per month. Yes, AI is good. But it costs a lot. And there is no way in it's current state it's going to be solving IOI problems for the average customer.

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

        But what's not being told is that google and microsoft consumed hundreds of thousands of dolars worth of electricity trying to get those scores,

        Did I reject that? Everyone knows this and it's neither a secret nor a surprise. The point is not that the model is too strong, it's that their "expected rating" isn't any different with regard to problems with different formats.

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

WOW

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

Similar type of problem

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

it might be helpful to share approx difficulty level of these problems so that I can decide if I should take part ...

I am fascinated by this new problem type, but also curious about why authors conceived of this new problem type.

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

A very interesting problem type. Looking forward to seeing these problems in following codeforces rounds!

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

Seems interesting... Let me too register for this and help in testing

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

new type of interactive-like problem, yum yum

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

As a non-tester, I hope to be a part of this testing round. (Does that actually make me a tester?)

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

As fun as it might be, I'm definitely cooked. I still haven't gotten the hang of interactive

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

Dope!

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

As a participant, am I going to test?

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

DREAMS DO COME TRUE

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

This is a testing round, so if I participate, I will be a tester.

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

Finally, codeforces supports communication problems!

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

Nice

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

i dont understand this

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

    It’s basically that your program is going to run twice (during each run the memory is going to erase). The judge is going to take the output from the first run and going to use as input for the second run. Think about implementing an algorithm that could perfectly reconstruct the original data.

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

It would be nice to have a "Communication" tag for these problems

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

:fire:

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

So the only CF round where all participants are testers !?!?

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

Very interesting problem type. Next update to this would be 'run k+1' times where k would be decided in the first run.

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

Bold of you to assume i have any communication skills

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

Will the tasks be similar to oj.uz communication? For example https://oj.uz/problem/view/JOI21_shopping

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

Hopefully, Olympiad organizers in Syria won't see this as a chance and decide to organize our TST on codeforces

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

can someone provide communication based problems difficulty wise from various platforms please ? atleast 5-6?

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

It is also possible that a problem is both interactive and run-twice.

I can imagine that this will be very tedious to debug without a grader :'(

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

I absolutely have no idea how this will work. Could someone please explain how it differs from conventional contest problems?

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

Can we just solve the problem in the first run and then transfer it through compression algorithms to the second run and then decode? Is this solution meant for these problems or not? Or, both is okay?

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

    Depends. You can check out the various type of problems of this format on the contest I linked above. Sometimes it's about devising a compression method, sometimes it can be about devising a way to make the data resistant to error, or sometimes it can be something else!

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

What will we get in the future? Simulation Problems?

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

AI cheaters: sobs...

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

Are the problems going to be actual problems? Or will it be print a + b difficulty to test that the grader doesn’t explode?

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

Is the purpose of this new problem-type to prevent cheating ?

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

In the Russian community, such tasks are called "Double-run tasks" (Задачи с двойным запуском). The most popular of them is to implement the "Hamming code" (you must encode and decode binary string)

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

So basically, Codeforces just said, “your code has short-term memory loss, deal with it.” Time to teach my program how to leave notes for its future self. :)

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

As a Participant, I am really excited for this contest.

»
6 months ago, hide # |
Rev. 3  
Vote: I like it +1 Vote: I do not like it

1392E - Omkar and Duck

Here is a nice run twice type problem

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

This was my first time doing communication problems and I hecking love these tasks but I'm an ICPC participant now 😭😭

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

I am a bit disapointed, because I allways get "Idleness limit exceeded on test 1" :/ No idea what is wrong.

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

This problem seems more like encryption and decryption kind of think..

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

This type of problem doesn’t have a corresponding error type, so you have no idea what went wrong.

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

This communication format is really awesome. Great to see CF trying out new stuff!

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

Someone please explain the approach for Problem C? Please give some hints.

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

    There's a problem D??

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

    There is no problem D. If you mean problem C, google Hamming code.

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

    Here's my approach.

    (First Phase) Use $$$1$$$ to $$$15$$$ bits to express $$$x$$$ (its binary expression) , then calculate the xor for these used bits. This will give you a number which is less than $$$16$$$ . So then save this number use $$$16$$$ to $$$19$$$ bits. Then finally, add $$$20$$$ when there is odd number of bits from $$$16$$$ to $$$19$$$ .

    (Second Phase) So, when change is at $$$16$$$ to $$$20$$$ , you can find it by calculate bits count of them. (Its parity will tell you whether it is changed or not) If it is changed, it tells us bits from $$$1$$$ to $$$15$$$ is right, then just calculate $$$x$$$ back. If it is not, calculate the xor for former $$$15$$$ bits using the same strategy and the value expressed by bits $$$16$$$ to $$$19$$$ . If the result is not $$$0$$$ , it will tell you the bit that is changed. Filp it and you will get the answer. If it is $$$0$$$ , then the set is unchanged(And of course you will know the answer then).

    Summing up the above,you are able to find the answer $$$x$$$ .

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

      Does this approach have a name? It is quite similar to Hamming code and almost as efficient as it (requires at most 1 more bit than Hamming codes).

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

        Well, I don’t know if it has a name or not because I think it up myself:) Actually, I would like to think that I was inspired by Hamming codes and the goals are similar.

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

Not sure if this has been mentioned before, but it would be nice to maybe introduce the communication problem tag!

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

I think the problems were very easy. But considering it was for testing purpose, its fine. But loved the theme anyways.

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

Kept on getting WA on test 9

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

    Check the constraints for the length of s

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

    Brdr I also get wrong answer then I read output format it shows string length. So, I get that you should focus on encoding to make sure your encoding should not produce larger string.

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

I enjoyed those new types of questions, codeforces should really add these in regular contests

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

Loved this Round, and the new concept ggs!!

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

How to solve B and how to use x?

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

    Without using x you can easily find [l, r] such that a[l] and a[r] are 1 and n or vice versa using binary search. You can use x to tell if l is 1 or n by setting x to 1 if the position of 1 is lesser than n in the original array

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

Really enjoyed the problems a lot. This is really interesting task type.

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

Why do you need to shuffle tests in B? And if this becomes a common practice in problemsetting, can you please not say the number of shuffled test in verdict?

I had wa1 in B with this message: "Second run message: wrong answer Guessed 2, Expected 1 (test case 2)". The tests look like this

first 3 3 3 2 1 5 1 2 3 4 5 5 4 2 3 5 1

But the answer to the second test is 5, not 1 nor 2. Turns out second case in the second run was [3, 2, 1] which is the first test in preview.

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

    Tests are shuffled in order to prevent sending information about what test case it is in the first run. But yes, we will ensure that this issue will not happen in communication problems in actual rounds.

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

      In order to prevent sending information wholly using multi-cases, you can also secretly split tests in the first phase into two or more parts and run them separately. For time limit, just sum them up(or maybe a max in case there’s initializations). I believe that adopt this strategy or mix them(I mean, both shuffle and split) together will block this method better.

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

Can we see how to set the tasks of TR20 with Polygon, as a sample?

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

I think it's time to add this line into our template:

while (t--)
{
    #ifdef MULTI_RUN
    string s; cin >> s; if(s.compare("first") == 0) solve(); else solve2();
    #endif
}
  • »
    »
    6 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    That fails for the problem B where the no. of test cases $$$t$$$ comes after the phase "first" or "second". The phase string will always come before the test case count because only one particular phase is expected per execution.

    Also, if (s == "first"sv) works fine, or you can also just compare the length of the string but that would lose clarity.

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

nice i am excited

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

i am excited

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

That seems brilliant and will introduce many new ideas and problems!

I just have a question for Proof_by_QED of any of who started this brilliant initiative: why limit to one-round communication? Is it possible that the problems will have multiple rounds as well? (May be $$$k \leqslant 20$$$ determined by the judge at the beginning of the problem)

Communication is a standard idea in Algorithms and Complexity Theory, so I'm excited for what this has to offer (for example, C in the testing round introduced the idea of error-correcting codes!)

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

Cool ideas Can anyone give some brief on the creative side of problems that could unlock or kind of a why such class of problems exist in general?

For A2,You can simply encode each digit to corresponding character, so at max 10 digits+ a separation character(to understand that was a number ending there), exactly fitting in the length(10^4*10), except for 10**9 you need to encode a separate character(otherwise wa on 9).

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

People working in different computational fields of computer science should try involving real-world applications in competitive programming on codeforce. It helps you grow in all directions, and such problems are really fun!

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

one more annoying type of problems! 2 times bigger code... O_o

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

Ok, so to be honest, at first I was very hesitant about communication problems and failed to see why they would be interesting at all, in fact both a and b were extremely easy and overall boring, quick to figure out, and nothing interesting. However, I admit C was cool, maybe one of my favourite problems of recent times

It was pretty easy to figure out

Spoiler

The

Spoiler

However then I got stuck as

Spoiler

Overall, very nice problem, and completely changed how I view communication problems, I think these are a welcome change to CF as long as they require creative never-before-seen (in cf) ideas

However, I still think B is a useless problem and I question why it exists? Its trivial and does not require any neat tricks in the first place.

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

Will there be communication problems in future rounds?

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

    Yes, there will. I think this will add some more fun problems and a little bit of spice to the round.

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

The new Communication Problems are one of my favorite type of problems. I can suggest you to look to the Ejoi 2020 day 2 Problem B Card Trick, if you want to solve more Communication Problems. https://eolymp.com/en/compete/c008c563-2b60-42ca-a5cf-1881ed4e2195/problem/2

Here is my solution.

Code
»
6 months ago, hide # |
 
Vote: I like it -20 Vote: I do not like it

hi

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

In C can there be multiple second runs? (I see that it runs exactly twice but can this be implemented?)

For example for each first run there are 21 second runs, one for each possible change. Or maybe just put everything in one run with 21x more testcases, but if there are no multiple testcases then that doesn't work.

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

    I also wanted to ask this because I was wondering whether tasks like APIO 2022 Mars can be implemented (where the second runner is called multiple times or at least in absence of previous memory)

    wait apparently it was already addressed in previous threads lol

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

Try CF Submitter : https://marketplace.visualstudio.com/items?itemName=DevXSayan.cf-submitter - Fetch all the problems of a contest inside vscode, run test cases, and submit in one click, all without leaving vscode

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

So it is interactive but not interactive also

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

Wow, this idea is really interesting. Now I’m thinking about a type of problem that involves executing the code K times (possibly more than twice). For instance, manually running a CNN. It might take a week for a submission to be judged. :)

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

I didn't really understand anything, but I'll pretend like I did... By the way, how do we solve communication problems? I mean, we are programmers...

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

Can someone explain what is the difference between just these types of problems and the previous already existing problem. We know that if the run is first then execute solve1 else execute solve2.

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

    The behavior of solve2 heavily depends on the behavior of solve1, it is not like you are solving two completely independent problems.

    One example, a task that requires you to prove that there is a bijection between two sets by constructing one can't be easily evaluated without this format.

    Check the problems in this contest: https://contest.ucup.ac/contest/1465

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

Hello, respected Codeforces coordinators. I received a plagiarism warning for submission 346344726 . I assure you that I did not share my code with anyone or copy from others intentionally. I might have used a similar approach or template that could have caused this similarity. If needed, I can provide my code history, local editor files, or screenshots showing my development process. I kindly request a recheck or reconsideration of this case. Thank you for your understanding and for maintaining fairness on the platform.[user:c231080_masrur][submission:346344726] ~~~~~ Your code here... ~~~~~

include <bits/stdc++.h>

using namespace std; using ll = long long;

int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; if (!(cin >> T)) return 0; while (T--) { int n; ll k; cin >> n >> k; vector<vector> adj(n+1); for (int i = 0; i < n-1; ++i) { int u,v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } vector parent(n+1, 0), order; order.reserve(n); parent[1] = 0; order.push_back(1); for (size_t i = 0; i < order.size(); ++i) { int u = order[i]; for (int v : adj[u]) if (v != parent[u]) { parent[v] = u; order.push_back(v); } } vector sz(n+1, 0); for (int i = n-1; i >= 0; --i) { int u = order[i]; sz[u] = 1; for (int v : adj[u]) if (v != parent[u]) sz[u] += sz[v]; } ll total = 0; for (int v = 1; v <= n; ++v) { ll cnt = 0; if (n >= k) cnt += 1; for (int u : adj[v]) { ll s_u; if (u == parent[v]) s_u = n — sz[v]; else s_u = sz[u]; if ((ll)n — s_u >= k) cnt += s_u; } total += cnt; } cout << total << '\n'; } return 0; }

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

I think that communication problems have good potential and I am looking forward to seeing them in future contests.

As others have mentioned it is now time to update code templates to handle them. I have also written some shell command lines that allow easier testing.

For problem A I have used:

./a.out < example.in | tee first.out && (echo "second" && cat first.out) | ./a.out

Where example.in is the input of the first execution. And a.out is the compiled binary.

For problem C we need to pass the number of test cases to the second program. The command now looks as follows:

./a.out < example.in | tee first.out && (echo "second $(sed -n '2p' < example.in)" && cat first.out) | ./a.out

It doesn't do communication mangling which was in C, and interactive problems still require special handling. However, I believe this should at least be helpful for most of such programs.

Feel free to use it and share your commands if you came up with something better.

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

tung tugnb tung saHUR

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

It seems that will have more great problem

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

orz

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

okay