wrusb's blog

By wrusb, history, 3 months ago, In English

How can this code AC? Is this code illegal?

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

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As far as I know, in Codeforces, your code might get skipped if you try to hide your code logic (so that no one can hack your code)

»
3 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Me when I code golf (this problem is rated 2100 btw) https://codeforces.me/contest/1930/submission/378903923

#include<bits/stdc++.h>
using namespace std;using L=size_t;int main(){L t;cin>>t;while(t--){L n;string s;cin>>n>>s;vector<L>d(n+9);for(L i=n;i;)d[i--]=s[i-1]=='0'?d[i+1]:(n-i+1)+d[i+3];cout<<accumulate(d.begin(),d.end(),0LL)<<"\n";}}

using L=size_t saves a byte vs long long or uint64_t but is INCREDIBLY cursed. And cursed loop strategy for(int i = n; i; ) d[i--] = ...

»
3 months ago, hide # |
 
Vote: I like it +56 Vote: I do not like it

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

UOC GIOI NHU NGAI

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What's the problem?