Codeforces Round #869 (Div.1, Div.2) Editorial
source link: https://codeforces.com/blog/entry/115586
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Problem idea: adamant
Preparation: adamant
Problem idea: adamant
Preparation: adamant
1817A - Almost Increasing Subsequence
Problem idea: dario2994
Preparation: jeroenodb
Problem idea: jeroenodb
Preparation: jeroenodb
Problem idea: adamant
Preparation: adamant
Problem idea: adamant
Preparation: jeroenodb
Problem idea: adamant
Preparation: adamant
Problem idea: adamant
Preparation: adamant
10 hours ago, # | Thanks for fast tutorial! |
10 hours ago, # | Light speed tutorial sheeeesh! |
10 hours ago, # | so fast |
10 hours ago, # | So fast! Noice |
10 hours ago, # | Why is it impossible for a python solution to pass div1C/div2E? |
9 hours ago, # | For Fish Graph, can you do a DFS-Tree like thing with which you can find the node with degree |
-
degree >= 4
won't ensure that that the tail of fish don't lie inside the cycle.-
i don't know what is wrong here, firstly i found every cycle and then check if it can be used as fish graph. but getting WA every time. Can anyone tell me what is wrong here? https://codeforces.com/contest/1818/submission/203991640
9 hours ago, # | For problem Div2.D I don't know this approach is correct or not: For each vertex with degree >= 4, find the shortest cycle through it, add those edges to answer, find another 2 vertices that are not in the found cycle, include those 2 edges as well. The wrong submission, the system verdicted WA, wrote that I'm using an edge twice, while I check again the output, it doesn't seem like that. 203958546 |
9 hours ago, # | 1818B - Indivisible seems to be repeated question |
9 hours ago, # | Problem ...and for the coefficient near we should note that , thus... What happenes on the next line? |
Alternative solution for 1817D - Toy Machine If the bottom left part of the toy is full, and it contains , you can win using AC submission: 203960705 |
9 hours ago, # | Little note: for E, you can tighten the bound to (possibly with some off-by-one). |
9 hours ago, # | |
-
TLE results that were non-trivial, i.e., you had to change ur code even the slightest, they don't regrade it.
9 hours ago, # | Toy Machine was fun. The web page was a great addition! |
9 hours ago, # | Really enjoyed the problems. Good work by the authors! |
9 hours ago, # | Is there a constructive way to figure out B? Or was it just observation? |
-
I have used the brute force approach to generate all possible answer to see any answer for each test case follow some pattern.
bool check(vector<int>& a,int n){ for(int i=0;i<n-1;i++){ int sum=a[i]; for(int j=i+1;j<n;j++){ sum+=a[j]; if(sum%(j-i+1)==0){ return false; } } } return true; } void solve() { int n;cin>>n; cout << "n: " << n << '\n'; vector<int> a(n); loop(0,n-1){a[i]=i+1;} do{ if(check(a,n)){ print(a); } }while(next_permutation(all(a))); cout << '\n'; }
if you run this code for small test, like from 1 to 11, you will observe that answer exist if n is even and if n==1, and for each n(keep in mind that it is even) there is permuatation which follow some pattern like
2 1 4 3 6 5 ..... n-2 n-3 n n-1
you can try the above code and check it out yourself
The only problem is that this brute force will work till n=11, after that it will take very long time to produce answer. So, we cannot check it for large test cases.
Also n=1 is the only odd number that produce valid answer which is 1 only.
9 hours ago, # | F can be solved with suffix automaton in . |
what is the point from problems like div2B ? problems that depends on a pattern/sequence is pointless |
9 hours ago, # | I believe D could be solved in O(n+m) Via DSU. To check if it is possible to reach a node from another would be O(1). And to erase edges, we would simply connect the nodes to a virtual node that sits independent from the graph. But I am not sure. . |
9 hours ago, # | Nice contest! Although my B failed the system test. |
9 hours ago, # | I used the same approach you mentioned in problem d fish graph , but it shows wrong answer. Here's my solution https://codeforces.com/contest/1818/submission/203940101 , I can't find wats wrong |
If there were no constraints that required the club president to remain in the club (that is, if we were just trying to maximize the number of remaining members), would problem div2 A still be solvable? |
9 hours ago, # | Problem Div1A can be solved another way. Let’s think how the subsequence is organized. It can be created greedy: let the last included integer be a[i]. 1) if a[i+1] > a[i], so the next subsequence’s number will be a[i+1]. 2) else we need to find the first j such that a[j] < a[j+1], and the next subsequence’s numbers will be a[j] and a[j+1]. This observation can be used to calculate next[i]. So the answer is built by jumping from l to next[l], next[next[l]]… while <= r. To answer queries fast we can just count binary jumps on next[] array. |
i think there's some problem in Problem D test cases. according to the statement, 1 <= m, n <= 2000 but in test 12, m = 0 in many testcases, that makes my submission 203956585 got WA. |
9 hours ago, # | Why is the leading coefficient of B(x-s) in 1C equal to 1? I think it's k. |
In the tutorial of D1C,
It should be "SA(x)=A(x+1)" |
jeroenodb thank you very much for interesting problems ! I would like to share the solution of problem D in O(N + M). We can divide all vertices according to the components of the edge biconnection, and solve the problem for each vertex (v) in 3 cases: 1) Check that V has 2 or more edges to the vertices of other components (take them as 2 tails), and at least 2 edges to the vertices of its own component (find a cycle) 2) Check that V has 1 edge to the vertex of the other component (take as 1 tail), and at least 3 edges to the vertices of its own component, taking one vertex as the tail, and find a cycle between the remaining two. 3) Check that V has at least 4 edges to the vertices of its own component and select 2 of the 4 vertices as parts of the tail and check that removing them from the component can find a path between the remaining two. Link to my solution: https://codeforces.com/contest/1818/submission/203962283 |
For C, it can be observed both polynomials have to be in the form . The problem can then be rephrased as finding . Taking the derivative gives us which means we can get or the answer by finding the differences. |
For Div1C, does anybody know why this submission is giving WA on test 5? Staring at code with no luck :) Many thanks. Edit: I found it. |
6 hours ago, # | Can anyone give a testcase in which the following code is giving wrong answer . Problem C div 2 Submission link Thanks |
4 hours ago, # | Thanks for Div1D/Div2F. |
3 hours ago, # | Very frustrated that my div2D submission (203945910) only failed because of a stack overflow. I wrote in Python, so a possible solution to this situation is to increase the stack limit using the method |
97 minutes ago, # | Can someone tell me why my binary search submission for Div 2 C is wrong? Thanks! |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK