# | User | Rating |
---|---|---|
1 | jiangly | 3756 |
2 | tourist | 3723 |
3 | orzdevinwang | 3696 |
4 | Kevin114514 | 3647 |
5 | Radewoosh | 3631 |
6 | ecnerwala | 3596 |
7 | Benq | 3527 |
8 | maroonrk | 3518 |
9 | ksun48 | 3484 |
10 | Nachia | 3463 |
# | User | Contrib. |
---|---|---|
1 | errorgorn | 170 |
2 | Qingyu | 165 |
3 | Dominater069 | 159 |
4 | cry | 157 |
4 | Um_nik | 157 |
6 | adamant | 155 |
7 | -is-this-fft- | 151 |
8 | djm03178 | 148 |
9 | soullless | 146 |
10 | chromate00 | 144 |
We will hold AtCoder Beginner Contest 400.
We are looking forward to your participation!
» | Hope this contest will not be as shit as the last ABC. =========================== update: very hard but is a good contest. |
» » |
» » | What happened in the last one ? Lemme guess — too standard or AI generated crap |
» » » |
» |
» | Good luck! |
» |
» | Good luck. |
» |
» | ABC 4e2! |
» |
» | ;( prob C was harder than prob D |
» |
» | C was much harder than D |
» |
» |
» » |
» » | I changed it to a Priority Queue implementation and it TLE'd on testcase 2 lol. |
» » » |
» » » | use deque for that, if the edge cost is 0 then you push the new node at the front, otherwise it will be at the back of the deque. |
» » » » |
» | I need c answer ,it is a difficult to make it |
» » | Binary search solution:64571484 The first intuition should be that you either iterate over $$$2^a$$$ or iterate over $$$b^2$$$. Iterating over $$$b^2$$$ takes too long since $$$b \le 10^9$$$, but iterating over $$$2^a$$$ is fast (only around 59 candidates). For each value of $$$2^a$$$, we need to find out how many values of $$$2^b$$$ are small enough to satisfy $$$2^a \cdot b^2 \le N$$$. We can just binary search over $$$b$$$, since for any $$$2^a \cdot b^2 \le N$$$, we also know that $$$2^a \cdot (b-1)^2 \le N$$$ (you can also just use sqrt instead of binary search). Also be careful not to overflow when doing calculations, you can replace potential overflowing statements likeif (x*y > N) withif (x > N/y). After this, the only remaining issue is the fact that some numbers are over-counted (for example, 72 is counted as both $$$2^1 * 6^2$$$ and $$$2^3 * 3^2$$$). This is because in some cases, our $$$b^2$$$ value contains factors of 2, which could equivalently be moved to $$$2^a$$$ instead. We can just ignore all values of $$$b^2$$$ which contain factors of two, which are just the even values of $$$b$$$. If we have $$$x$$$ values of $$$b$$$ for which $$$2^a \cdot b^2 \le N$$$, then we have exactly $$$\lceil \frac{x}{2} \rceil$$$ odd values of $$$b$$$. |
» » » |
» » » | Just want to add a little bit, it is not necessary to check $$$a = 1, 2, 3 ... 60$$$. Simply checking $$$a = 1$$$ and $$$a = 2$$$ is enough. This is because for odd value of $$$a$$$, $$$2^{a}b^{2}$$$ can be written as For even, it can be written as: |
» |
» | Can someone explain to me what is wrong with my solution to problem C:
Passed almost all the test except for 4 test cases |
» » | So here is some technical stuffs if you want to know why:
|
» | Can someone please help me with my C submissionhttps://atcoder.jp/contests/abc400/submissions/64549973 I counted all the perfect squares before N and the biggest power of 2 before N. And then counted their number of combinations. |
» » | So here is some technical stuffs if you want to know why:
But I would still suggest that you use binary search instead for this lol. |
» |
» | Good F |
» | O(1) complexity solution for C:
|
» | I solved D with dijkstra. Is it overkill or was that an intended solution? |
» » |
» |
» | how to solve F? |
» » | First consider a regular array rather than a cyclic one. Each time we introduce a new number $$$C[i]$$$, we can give it a segment width of 1 and we pay $$$1+X[C[i]]$$$. We could also instead extend this segment to a previous occurrence of $$$C[i]$$$: if this previous occurrence is at index $$$j$$$ then we simply pay $$$i-j$$$ (with no X cost). However, if we do this, then any segments from $$$j+1$$$ to $$$i-1$$$ cannot extend outside of this range, and same for any segments from $$$0$$$ to $$$j-1$$$. We can maintain $$$dp[l][r]$$$ as the min cost of the subarray $$$C[l:r]$$$. If we're introducing a new number at index $$$r$$$ (currently with a segment width of 1), and we want to extend this segment to a previous occurrence of $$$C[r]$$$ at index $$$m$$$, then for all $$$l$$$ we can have $$$dp[l][r] = \min(dp[l][r], dp[l][m] + (r-m) + dp[m+1][r-1])$$$: the cost up until the previous occurrence, the cost of extending the segment, and the cost of the subarray inside of the extended segment. As an alternative, by not extending, we simply have $$$dp[l][r] = dp[l][r-1] + 1 + X[C[r]]$$$. To deal with the cyclic array, just set C = C+C, solve with the above method, and then select the best size-N window with $$$dp[i][i+N-1]$$$ in order to check all cyclic shifts. Solution:64571967 |
» » » |
» | This is some code ~~~~~~~~~ //#include include<string.h>includeincludeusing namespace std; typedef long long LL; const int N=1e6; const int MAXN=3e6; int isnp[N]; LL cnt[MAXN]; void init(int n){ for(int i=2;i*i<=n;i++){ if(isnp[i]==0){ for(int j=i;j<=n;j+=i){ isnp[j]++; } } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); memset(isnp,0,sizeof(isnp)); memset(cnt,0,sizeof(cnt)); init(N); int m; int ans=0; for(int i=2;i<=N;i++){ if(isnp[i]==2){ cnt[++ans]=i*i; } } cin>>m; while(m--){ LL x; cin>>x; int p=ans; int k=upper_bound(cnt+1,cnt+ans+1,x)-(cnt+1); cout<<cnt[k]<<'\n'; } return 0; } // ~~~~~~~~ I don't know what's problem in my code,may be binary_search but I can't work out it ,who can help me |
» |
» | why solved problem is not updated on atcoder kenkooo |
» |
» | Solve C in O(1): ~~~~~ include <bits/stdc++.h>using namespace std; define int long longsigned main() { int n;cin>>n; cout<<(long long)(sqrtl(n/2))+(long long)(sqrtl(n/4))<<endl; } ~~~~~ |
» | editorial for D? |
» » |
» | In the editorial for problem F, when analyzing the recurrence for dp[l][r], the following case is discussed: "Next, suppose that the last operation was performed against pieces l, l+1, ..., r−1. The sought cost is the minimum cost required to make each of the pieces l, l+1, ..., r−1 either color 0 or color C[l], plus r − l + X[C[l]]. (Note that piece l remains color C[l].)" This corresponds to the case where the last operation is applied to the segment [l, r). My question is: Why do we only consider converting the segment [l, r) to either color 0 or the color C[l]? Wouldn't it make more sense to consider converting the segment to any color, not just C[l]? Imagine there's a large portion of the segment [l, r) that is already of some other color d, and the cost X[d] is very low. In that case, wouldn't it be better to convert the segment to color d, instead of being restricted to just 0 or C[l]? the editorial says: "Note that piece l remains color C[l]." Why is it always optimal to leave piece l as color C[l]? Isn’t it possible that changing l to match the rest of the segment might lead to a lower cost overall? I came across [user:cowmane]’s solution, and I found that approach more intuitive. But I want to understand why the editorial's version is still valid or even better. |
Name |
---|