Thanks everybody for participating in the round!
Author: BernatP Preparation: BernatP
Hint1How big can the answer be?
Hint2Which coordinates can you reach in $$$2$$$ or $$$3$$$ moves?
Code#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--){
int x,y;
cin>>x>>y;
if(x==y || x==y+1 || y==1)cout<<-1<<endl;
else if(x<y)cout<<2<<endl;
else cout<<3<<endl;
}
}
Author: danx Preparation: danx
Hint1Don't over complicate, there is a simple construction
Hint2There is a construction where each number $$$x$$$ is placed at distance either $$$x$$$ or $$$2 \cdot x$$$.
Hint3Here is a construction where only the number $$$n$$$ is placed at distance $$$n$$$. All other numbers are placed at distance $$$2 \cdot x$$$.
Hint4There is a construction where the first element of the array is always $$$n$$$.
Code#include <bits/stdc++.h>
using namespace std;
int t, n;
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> t;
while (t--) {
cin >> n;
for (int i = n; i >= 1; i--) {
cout << i << " ";
}
cout << n;
for (int i = 1; i < n; i++) {
cout << " " << i;
}
cout << "\n";
}
}
Author: misteg168 Preparation: misteg168
Hint1If we have two consecutive $$$1$$$'s, the rabbits on the left and right of this block are independent. We can divide our problem into multiple subproblems.
Hint2If one of these subproblems mentioned in hint $$$1$$$ contains two consecutive 0's, can we solve this subproblem?
Hint3If we don't have consecutive $$$0$$$'s in these subproblems mentioned in hint $$$1$$$, the pattern looks like $$$10101 \dots 10101$$$, in which of these patterns can we place the rabbits?
Code#include <bits/stdc++.h>
using namespace std;
void solve() {
int n; cin >> n;
string s; cin >> s;
bool ok = true;
bool curr = (s[0] == '1');
int cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '0')
cnt++;
if (i == 0)
continue;
if (s[i] == s[i-1] && s[i] == '0')
curr = false;
if (s[i] == s[i-1] && s[i] == '1') {
if (curr && cnt % 2 == 1)
ok = false;
curr = true;
cnt = 0;
}
}
if (curr && cnt % 2 == 1 && s[n-1] == '1')
ok = false;
cout << (ok ? "YES" : "NO") << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while (T--)
solve();
}
Author: BernatP Preparation: BernatP
Hint2What happens when every value is even?
Hint3How can we add exactly one odd number to the solution of hint 2?
Author: Pablo-No Preparation: Pablo-No
Hint1The answer is bounded by $$$31$$$.
Hint2We will precalculate the minimum operations for each answer.
Hint3How will the bitwise or look like if we want to increase the popcount from the original by increasing the number of $$$1$$$'s.
Hint4We can show that it is better to fill the least significant $$$0$$$'s first.
Hint5What is the best way to fill a certain bit.
Hint6The solution is a greedy algorithm.
CodeSolve the problem in $$$\mathcal{O}(n b + t b^2 + q \log (b))$$$.
Author: BernatP Preparation: misteg168
Hint1Try to understand what are the SCCs.
Hint2They are a line. Given the sizes of the SCC, find a closed formula for the answer.
Hint3Think how to maintain the formula using data structures.
Author: BernatP Preparation: BernatP
About cheatersThere was a lot of cheating on this problem, which is why there were many in-contest solves. Cheaters will be banned. We’re sorry if the high solve count during the contest misled anyone, but please understand that this isn’t something the authors, coordinators, or codeforces can control.
Hint1What happens when $$$n$$$ is big?
Hint2$$$b_n$$$ is $$$a^{a^N}$$$ for some big $$$N$$$.
Hint3Given $$$a$$$ and $$$m$$$ find a condition for $$$a$$$ to be $$$m$$$-tetrative.
Hint4The condition is $$$\forall p|ord_m(a), p|a$$$.
Hint5Fix the number of values of $$$a$$$ such that $$$ord_m(a) = k$$$ and get a formula.
Hint6If $$$m$$$ is an odd prime power, the number above for $$$k|\varphi(m)$$$ is $$$\varphi(k)$$$.
Hint7Manipulate the formula until it only depends on the prime divisors of $$$\varphi(m)$$$ that are not in $$$m$$$.
Hint8Factor it to calculate it in $$$O(\log m)$$$.
Author: FelixMP Preparation: FelixMP
Hint1Think of min-cut instead of max-flow.
Hint2Can you think of a sufficient condition so that all the min-cuts between any pair of vertices are divisible by the same number?
Hint3In fact, the expected sufficient condition implies that all cuts of the graph (not just min-cuts) are divisible by the same number.
Hint4The minimum number of colors is always $$$1$$$ or $$$2$$$. You can check if the answer is $$$1$$$ by brute force.
Hint5It is possible to make all cuts even in each induced subgraph using just $$$2$$$ colors.
Author: BernatP Preparation: BernatP
Hint1The expected is $$$n = mlogm - O(m)$$$ steps using harmonic sum.
Hint2Think of a solution in 2D (not needed but good intuition).
Hint3Put points as an almost regular polygon and keep doing circles around it jumping with step $$$1$$$, then $$$2$$$, then $$$3$$$...
Hint4Think how to project this solution to 1D
Author: BernatP Preparation: BernatP
Hint1There is a $$$n = 2m-3$$$ solution that will be useful: given two groups of points in arithmetic progression far enough apart you can add two pivots in the middle to keep jumping from the left to the right group: ..... .. .....
Hint2The goal is to recursively construct a solution using smaller ones.