Submission #306572

#TimeUsernameProblemLanguageResultExecution timeMemory
306572peti1234Painting Squares (IOI20_squares)C++17
100 / 100
447 ms772 KiB
#include <bits/stdc++.h> #include "squares.h" using namespace std; const int c=512; int n; vector<int> sol, s, ans, sz[c]; bool v[c][2]; void dfs(int a) { if (!v[a][0]) { v[a][0]=1, dfs(sz[a][0]); s.push_back(0); } if (!v[a][1]) { v[a][1]=1, dfs(sz[a][1]); s.push_back(1); } } vector<int> paint(int N) { n=N; for (int i=0; i<c; i++) sz[i].clear(), sol.clear(), s.clear(), ans.clear(), v[i][0]=0, v[i][1]=0; for (int i=0; i<c; i++) { int x=2*i%c; sz[i].push_back(x), sz[i].push_back(x+1); } dfs(0); for (int i=0; i<9; i++) sol.push_back(0); while(s.size()>0) sol.push_back(s.back()), s.pop_back(); for (int i=0; i<n; i++) ans.push_back(sol[i]); ans.push_back(min(10, n)); for (int i=0; i<10; i++) sol.push_back(-1); for (int i=n; i<n+10; i++) sol[i]=-1; return ans; } int find_location(int n, vector<int> kerd) { int k=kerd.size(); for (int i=0; i<c; i++) sz[i].clear(), sol.clear(), s.clear(), ans.clear(), v[i][0]=0, v[i][1]=0; for (int i=0; i<c; i++) { int x=2*i%c; sz[i].push_back(x), sz[i].push_back(x+1); } dfs(0); for (int i=0; i<9; i++) sol.push_back(0); while(s.size()>0) sol.push_back(s.back()), s.pop_back(); for (int i=0; i<n; i++) ans.push_back(sol[i]); ans.push_back(min(10, n)); for (int i=0; i<10; i++) sol.push_back(-1); for (int i=n; i<n+10; i++) sol[i]=-1; for (int i=0; i<n; i++) { bool jo=1; for (int j=0; j<k; j++) { if (sol[i+j]!=kerd[j]) jo=0; } if (jo) return i; } return n; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...