Submission #592081

#TimeUsernameProblemLanguageResultExecution timeMemory
592081zaneyuPainting Squares (IOI20_squares)C++14
100 / 100
110 ms1028 KiB
#include "squares.h" #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; //#pragma GCC target("avx2") //order_of_key #of elements less than x // find_by_order kth element #define ll long long #define ld long double #define pii pair<int,int> #define f first #define s second #define pb push_back #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define FILL(n,x) memset(n,x,sizeof(n)) #define ALL(_a) _a.begin(),_a.end() #define sz(x) (int)x.size() #define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end())))) const ll maxn=2e3+5; const ll maxlg=__lg(maxn)+2; const ll INF64=4e18; const int INF=0x3f3f3f3f; const ll MOD=1e9+7; const ld PI=acos(-1); const ld eps=1e-6; #define lowb(x) x&(-x) #define MNTO(x,y) x=min(x,(__typeof__(x))y) #define MXTO(x,y) x=max(x,(__typeof__(x))y) template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<P.f<<' '<<P.s; return out; } template<typename T> ostream& operator<<(ostream& out,vector<T> V){ REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?" ":"\n"); return out; } ll mult(ll a,ll b){ return a*b%MOD; } ll mypow(ll a,ll b){ a%=MOD; if(a==0) return 0; if(b<=0) return 1; ll res=1LL; while(b){ if(b&1) res=(res*a)%MOD; a=(a*a)%MOD; b>>=1; } return res; } unordered_map<string,bool> vis; string ans=""; int mp[maxn]; void dfs(string cur){ string tmp=cur+'0'; if(!vis.count(tmp)){ vis[tmp]=1; dfs(tmp.substr(1)); ans.pb('0'); } tmp=cur+'1'; if(!vis.count(tmp)){ vis[tmp]=1; dfs(tmp.substr(1)); ans.pb('1'); } } void gen(){ if(sz(vis)) return; ans.clear(),vis.clear(); string s=""; REP(i,9) s.pb('0'); dfs(s); ans+=s; REP(i,sz(ans)-9){ int x=0; REP(j,10){ x=x*2+(ans[i+j]-'0'); } mp[x]=i; } } std::vector<int> paint(int n) { vector<int> v(n+1,0); v[n]=10; gen(); REP(j,n) v[j]=ans[j]-'0'; return v; } int find_location(int n, std::vector<int> c) { gen(); int x=0; REP(j,10){ if(c[j]==-1){ return n-j; } x=x*2+c[j]; } return mp[x]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...