BERNARB.01's blog

By BERNARB.01, 13 days ago, In English

Hello, I was solving the problem 461B - Appleman and Tree but misread the problem statement — thinking that I have to calculate the number of ways such that each subtree has at least one black node, but I couldn't find a solution to this. Can anyone help me with this version of the problem?

Read more »

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

By BERNARB.01, history, 15 months ago, In English

Hello codeforces,

On this problem 1277E - Две ярмарки, there is t test cases and I am using a vector<vector> ed(N) to store the edges of the graph, so in end of each test case I need to clear my vector ed so I created another one vector<vector> em(N) and it's empty all the running time, in the end of each test case I did ed = em to save time, but I were always getting a TLE on the 2nd test, and I don't know why. In the first submission 68468115, I did

vector<vector<int> > ed(N), em(N);
int main() {
  cin >> t;
  while(t--){
    ...
    ...
    ...
    ed = em;
  }
  return 0;
}

But when I did the following in this submission 68489443, I got an AC.

vector<vector<int> > ed(N);
int main() {
  cin >> t;
  while(t--){
    ...
    ...
    ...
    for(int i=0; i<n; i++) ed[i].clear();
  }
  return 0;
}

Can someone explain why I were getting a TLE on the first submission, even that in the first submission I were doing one operation but in the second one I were doing N operations.

Read more »

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