Submission #367549

#TimeUsernameProblemLanguageResultExecution timeMemory
367549rocks03Painting Squares (IOI20_squares)C++14
0 / 100
133 ms828 KiB
//#pragma GCC target("avx2") //#pragma GCC optimization("O3") //#pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 1000+100; char A[] = {'0', '1'}; int vis[MAXN]; vector<int> edges; int K = 10; void dfs(int v){ rep(k, 0, 2){ int u = ((v << 1) & ((1 << K) - 1)) + A[k]; if(!vis[u]){ vis[u] = true; u &= ((1 << K) - 1); dfs(u); edges.pb(k); } } } bool done = false; string de_bruijn; map<int, int> mp; void init(){ if(done) return; done = true; int start = 0; dfs(start); rep(i, 0, (1 << K)){ de_bruijn += A[edges[i]]; } rep(i, 0, (1 << K)){ if(i + K < (1 << K)){ int n = 0; rep(j, i, i + K){ n += ((de_bruijn[j] - '0') << (j - i)); } mp[n] = i; } } } vector<int> paint(int n){ // construct de bruijn sequence init(); vector<int> v(n); rep(i, 0, n){ v[i] = de_bruijn[i] - '0'; } int K = 10; v.pb(K); return v; } int find_location(int n, vector<int> c) { int f = 0; for(int x : c){ f += (x == -1); } if(f){ return (n - (SZ(c) - f)); } int p = 1; for(int x : c){ f += p * x; p <<= 1; } return mp[f]; }

Compilation message (stderr)

squares.cpp: In function 'void init()':
squares.cpp:41:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   41 |     if(done) return; done = true;
      |     ^~
squares.cpp:41:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   41 |     if(done) return; done = true;
      |                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...