Блог пользователя chokudai

Автор chokudai, история, 6 лет назад, По-английски

We will hold AIsing Programming Contest 2020.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +99
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

Can we expect it's difficulty to be similar to normal ABC's?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

the timing is a little bit confusion.It collides with #655 div2 on codeforces right? Can anyone tell me the start time in india?

»
6 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +2 Проголосовать: не нравится

Strange registration time?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Good luck!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -158 Проголосовать: не нравится

include

using namespace std;

int main() { int n; cin>>n;

int arr[n+1];

for(int i=0;i<n;i++) { arr[i]=0; }

int x=1,y=2,z=2;

while((6*x*x)<=n) { arr[(6*x*x)-1]=1; x++; }

while(((y+1)*(y+1)+2)<=n) { arr[((y+1)*(y+1)+1)]=3; y++; }

while(((z+1)*(z+1)+2*z*z)<=n) { arr[((z+1)*(z+1)+2*z*z-1)]=3; z++; }

for(int i=0;i<n;i++) { cout<<arr[i]<<endl; }

return 0;}

CAN ANYBODY TELL ME WHERE I'M GOING WRONG?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

How to solve E? Ternary search? We try placing all elements having l > r to left, r > l to right and add k for l = r. The answer will first increase and then decrease based on how many elements we place having l > r on left?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

How to solve F,I just came up with a solution of $$$O(5*n^2)$$$

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +12 Проголосовать: не нравится

I solve C by calculating all data on my laptop :|
Can I break longest code on atcoder ?
Here is my code .
Picture
:|

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

Can anyone help with question D? I mean, was there a pattern or something, that I missed? I understood this that after the first modulo operation, a simple approach would do, but how was I to find the remainder of such a large number with the count of it's set bits?

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    the trick was to just precalculate those big numbers modulo the bitcount

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    After just one operation ,no matter what X is intially, X will become <200000. Now just precalculate answers for all y<200000. To find what X will become after first operation i.e after inverting a bit ,use modexp.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    In the first step you have to calculate a large number modulo $$$x$$$, where $$$x$$$ is the number of set bits. Note that, the large number is a sum of some powers of two, so just add those powers of two modulo $$$x$$$, can be done in $$$O(n)$$$ or $$$O(nlogn)$$$. One simple observation on the problem is, once you toggle a bit $$$x$$$ increases or decreases by one. So first calculate two values, one is the large number modulo $$$x-1$$$ and the other being large number modulo $$$x+1$$$. After that for each of the toggled bit its easy to do the operation once. After that whatever number you get is going to be less than $$$n$$$. Then as you've mentioned proceed normally.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +6 Проголосовать: не нравится

    There are only two possible bitcounts (the original plus one and the original minus one).

    You can determine the original value of S modulo both of these (2 numbers; each takes O(n) to compute). Then each bit flip means adding or subtracting a power of 2 to the original value of S (constant time). So all of the initial values can be computed in O(n) time.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    The idea in D is that only the first mod operation is on huge number, all others are on numbers in int range, and not much operations at all.

    So we find a way to calc the first mod operation. Note that there are only two possible number of bits we have to consider. This is the initial number +1 or -1.

    Therefore we calculate the mod value of the original long string for those both mods. Then we go from left to right, and add the mod value of this single position to the sum (one of them, depending if current symbol is 1 or 0). The mod value of the current position can be calculated using power() function.

    see for example code

  • »
    »
    6 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +6 Проголосовать: не нравится

    Look after the first modulo operation x will be between 0 to cnt-1, cnt = number of 1. Then the binary representation will have 0-20 digits as log2(N) < 20. Then it's easy.

    So we have to calculate the mod of first operation. Now the problem is X is huge. X can be written as X = sum of power of 2 from binary representation. And for every position in the binary string the number of 1 will be cnt+1 if S[i] = 0 or cnt-1 if S[i] = 1. So for this two we will calculate the module of X in O(n) operation.Let, after first operation X becomes a.

    Now for pos 0 to n-1
    if S[pos] = 0
       a = (X + pow(2, n-1-i))%(cnt+1)
    else
       a = (X - pow(2, n-1-i))%(cnt-1)
    
    

    This way we can handle the first operation. Another special case is cnt = 1, Then if S[pos] = 1, output will 0. Here is my Code

    • »
      »
      »
      6 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Hey I'm unable to understand this, what happens if N=2e5 and the string has all 1 set.

      In that case it would be having 2e5 as popcount. I'm unable to wrap this fact,can you clarify more. Thanks!

      • »
        »
        »
        »
        6 лет назад, скрыть # ^ |
        Rev. 3  
        Проголосовать: нравится 0 Проголосовать: не нравится

        If the string size 2e5 having all 1 in the string, then cnt =2e5. So after first mod operation X must become 0 to 2e5-2, X = the number of whose binary string is given. Let, it becomes X = 2e5-2 after first operation.Now for the second operation cnt must be less than 20 as log2(2e5-2)<20.Then we can check untill X becomes 0 as it will be a very few moves. And the first operation I tried to explain in my first comment....

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks, everyone for helping! I had missed the fact that I could calculate the remainder by summing up the remainders from each bit (raising 2 to the power and then taking the remainder and then summing up). I feel silly.. lol!

    Anyways, upsolved! code

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

how to solve C

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -64 Проголосовать: не нравится

import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(reader.readLine()); char[] list = reader.readLine().toCharArray(); int clip = 0; for(int i = 0;i<n;i++){ if(list[i]=='1') clip++; } int[][] rems = new int[2][n+1]; ArrayList l = new ArrayList<>(); l.add(-1); l.add(1); for(int i=0;i<2;i++){ int temp = clip + l.get(i); for(int j = 0;j<=n;j++){ if(temp==0){ rems[i][j] = 0; continue; } if(j==0) rems[i][j] = 1%temp; else rems[i][j] = (rems[i][j-1]*2)%temp; } } int[] remlist = new int[2]; for(int i = 0;i<2;i++){ int temp = clip + l.get(i); for(int j = 0;j<n;j++){ if(list[j]=='1'){ remlist[i] = (remlist[i]+rems[i][n-j-1])%temp; } } } for(int i = 0;i<n;i++){ if(list[i]=='1'){ if(clip==1){ writer.write(1+"\n"); continue; } int lp = ((remlist[0] — rems[0][n-i-1]) + (clip-1))%(clip-1); writer.write((1+solve(lp))+"\n"); } else{ int lp = (remlist[1] + rems[1][n-i-1])%(clip+1); writer.write((1+solve(lp))+"\n"); } } writer.flush(); } public static int solve(int p){ if(p==0) return 0; int temp = p; int cnt = 0; while(p>0){ if(p%2==1) cnt++; p=p>>1; } if(cnt==0) return 1; return 1 + solve(temp%cnt); } } here is my code for D don't know why ia am getting RE in 5 cases else all are AC

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

If I have a value x which is n % m1.

Is there a way to get value n % m2 using x, m1 and m2 ?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

All our queries will be solved when secondthread puts out his screencast.....meanwhile happy upsolving....

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

greedy in E.??

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D? I have wasted lots of time on C just for finding the pattern then I realised I can pre calculate the values.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    store the ans for ans1=x%(popcount(x)-1) and ans2=x%(popcount(x)+1) precalculate value for 1<=i<=2*10^5 using dp {dp[i]=1+dp[i%(__builtin_popcount(i))])}

    then answer queries as if(s[i]=='1') {if(popcount(x)==1) cout<< 0 ; else cout<<1+dp[(c-1+(ans1-pow(2,n-i-1))%(c-1)];} else cout<<1+dp[(ans2+pow(2,n-i-1))%(c+1)];

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

was that a rated contest?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

really love questions specially problem D. here is my submission. submitted after 10 wrong attempts.

https://atcoder.jp/contests/aising2020/submissions/15180168 good contest!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can any one explain me the approach of D no problem ? I was just implementing what has been told in question but it gives me RE.Thanks in advance

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This time difficulty of D is more than usual AtCoder(abc)-D btw Loved Problem-D so much :)

If need help - https://atcoder.jp/contests/aising2020/submissions/15177397

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Hello, I'd appreciate any help knowing why the following logic for E is wrong (I've spent over 1.5+ hours cross-checking it with brute force generators+checkers, and finally found a failing case of n = 85k. However, somehow it fails all testcases on atcoder).

First, I sort all those with l>r in decreasing order, and consider them one by one. I update the fenwick tree at point K, if sum(0,K) <= K+1 for the current query (which implies I have not filled my quota for this prefix). Thus, you could say I am greedily assigning them.

Similarly, for those with l<r, I try to assign them to the point K+1 greedily (the next available point). Is there an easy failing testcase for the above?

Code can be found here

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What is the solution to E?

I tried greedy. Sort by |L-R|, and then try to add camels one-by-one taking the higher value. How do you tell if you can put a camel in the first K? (or last K). Let P[k] be the number of camels that have been placed in the first k spots. Then we must have \sum_{i=0}^j P[i] <= j+1 for each j. Keep track of these partials sums in a segtree. Adding a single camel means subtracting 1 from a range in the segtree. If the global min becomes negative, adding the camel is not allowed.

Is the idea above right?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I am getting runtime error for problem D. https://atcoder.jp/contests/aising2020/submissions/15184028 Please suggest some test cases.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +69 Проголосовать: не нравится

F answer in case anyone is wondering

F-ans

»
6 лет назад, скрыть # |
Rev. 6  
Проголосовать: нравится 0 Проголосовать: не нравится

I reduced $$$F$$$ to finding $$$\displaystyle\sum_{i=0}^{\left\lceil \frac{n}{2}\right\rceil -3}\binom{i+4}{4}\binom{n+5-2i}{10}$$$. Any ideas on how to simplify this to run in $$$O(1)$$$?

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone help me, please? Getting Runtime Error in Problem D. Here is my code: https://atcoder.jp/contests/aising2020/submissions/15178586 Thanks for your time.

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    You are trying to create an integer from 200k bits... that does not work. But is not nessecary, too. You can put the string into the constructor of bitset.

    I assume the error comes from the fact that you do %bitset.count() later, which is sometimes 0, hence you get a division by 0.

    However, if you fix this the code will still most likely TLE. The idea is to find a faster implementation than brute force. more explanation

            long long int x = stoi(temp,0,2);
            bitset< 200002 > bits(x);
    
»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Could someone help me with my WA code on problem D. I use the same idea as many people here but get WA on 4 test cases. I cannot find out the mistake. Thanks in advance. My submission

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi there, I am new at Atcoder can anyone help me where can I find tutorial in English.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

When will the English Editorial be published?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

If anyone is having difficulty with D , Here is a detail explanation(not a video tutorial) of D Here

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Will there be an AB(G?)C this Sunday?