Submission #3390308
Source Code Expand
#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; #define fi first #define se second #define mp make_pair #define pb push_back typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef unsigned long long ull; typedef long double ld; typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds; int a[(1<<18)+10]; vi get_rank(vi V) { int n = V.size(); if(n==1) return {V[0]}; vi L,R; for(int i=0;i<n;i+=2) { L.pb(min(V[i],V[i+1])); R.pb(max(V[i],V[i+1])); } vi rankL = get_rank(L); vi rankR = get_rank(R); for(int v:rankR) rankL.pb(v); return rankL; } void brute() { vi perm; int n = 3; for(int i=0;i<(1<<n);i++) perm.pb(i); do { cerr<<"INITIAL :\n"; for(int v:perm) { cerr<<v<<' '; } cerr<<'\n'; vi rankings = get_rank(perm); cerr<<"RANKINGS :\n"; for(int v:rankings) { cerr<<v<<' '; } cerr<<'\n'; bool pos=1; for(int i=0;i<n;i++) { for(int j=0;j<(1<<n);j++) { int u = j; int v = j^(1<<i); if((u<v)^(rankings[u]<rankings[v])){pos=0; break;} } if(!pos) break; } if(!pos) { for(int v:perm) cout<<v<<' '; return ; } }while(next_permutation(perm.begin(),perm.end())); } bool visited[(1<<18)+12]; int ranking[(1<<18)+12]; vi V; int n; void dfs(int u) { if(visited[u]) return ; V.pb(u); visited[u]=1; for(int i=0;i<n;i++) { if(u&(1<<i)) { dfs(u^(1<<i)); } } } bool used[(1<<18)+12]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); //brute(); return 0; cin>>n; for(int i=0;i<(1<<n);i++) { cin>>a[i]; a[i]--; } if(a[0]>=1){cout<<"NO\n"; return 0;} memset(ranking,-1,sizeof(ranking)); vector<ii> vec; for(int i=0;i<(1<<n);i++) { if(a[i]>=0) vec.pb(mp(a[i],i)); } vec.pb(mp(0,0)); vec.pb(mp((1<<n)-1,(1<<n)-1)); sort(vec.begin(),vec.end()); vec.erase(unique(vec.begin(),vec.end()),vec.end()); int pos=0; for(int i=0;i<vec.size();i++) { int needpos = vec[i].fi; int id = vec[i].se; if(used[needpos]){cout<<"NO\n"; return 0;} /* for(int i=0;i<(1<<n);i++) { cerr<<ranking[i]+1<<' '; } cerr<<"NEEDPOS "<<needpos<<" ID "<<id<<'\n'; */ V.clear(); dfs(id); sort(V.begin(),V.end()); //cerr<<V.size()<<' '<<pos<<'\n'; for(int i=0;i+1<V.size();i++) { while(used[pos]) pos++; if(pos>=needpos){cout<<"NO\n"; return 0;} used[pos]=1; ranking[V[i]] = pos++; } ranking[id] = needpos; used[needpos]=1; } /* for(int i=0;i<(1<<n);i++) { cerr<<ranking[i]+1<<' '; } cerr<<'\n'; */ vi res; res.pb(0); for(int i=0;i<n;i++) { vi nw; for(int v:res) { nw.pb(v); nw.pb(v+(1<<i)); } res=nw; } for(int i=0;i<(1<<n);i++) res[i]=ranking[res[i]]; cout<<"YES\n"; for(int i=0;i<(1<<n);i++) { cout<<res[i]+1; if(i+1<(1<<n)) cout<<' '; } cout<<'\n'; }
Submission Info
Submission Time | |
---|---|
Task | I - Full Tournament |
User | zscoder |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3048 Byte |
Status | WA |
Exec Time | 94 ms |
Memory | 9456 KB |
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1600 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt, 01-57.txt, 01-58.txt, 01-59.txt, 01-60.txt, 01-61.txt, 01-62.txt, 01-63.txt, 01-64.txt, 01-65.txt, 01-66.txt, 01-67.txt, 01-68.txt, 01-69.txt, 01-70.txt, 01-71.txt, 01-72.txt, 01-73.txt, 01-74.txt, 01-75.txt, 01-76.txt, 01-77.txt, 01-78.txt, 01-79.txt, 01-80.txt, 01-81.txt, 01-82.txt, 01-83.txt, 01-84.txt, 01-85.txt, 01-86.txt, 01-87.txt, 01-88.txt, 01-89.txt, 01-90.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 1280 KB |
01-02.txt | AC | 2 ms | 1280 KB |
01-03.txt | WA | 2 ms | 1280 KB |
01-04.txt | WA | 4 ms | 1536 KB |
01-05.txt | WA | 75 ms | 5928 KB |
01-06.txt | WA | 74 ms | 5928 KB |
01-07.txt | WA | 72 ms | 5928 KB |
01-08.txt | WA | 71 ms | 5928 KB |
01-09.txt | WA | 72 ms | 5928 KB |
01-10.txt | WA | 72 ms | 5928 KB |
01-11.txt | WA | 78 ms | 6640 KB |
01-12.txt | WA | 86 ms | 7024 KB |
01-13.txt | WA | 80 ms | 9200 KB |
01-14.txt | WA | 77 ms | 7152 KB |
01-15.txt | WA | 73 ms | 6640 KB |
01-16.txt | WA | 81 ms | 9200 KB |
01-17.txt | WA | 94 ms | 9456 KB |
01-18.txt | WA | 93 ms | 9328 KB |
01-19.txt | WA | 87 ms | 9072 KB |
01-20.txt | WA | 89 ms | 9200 KB |
01-21.txt | WA | 83 ms | 9200 KB |
01-22.txt | WA | 85 ms | 8944 KB |
01-23.txt | WA | 77 ms | 6508 KB |
01-24.txt | WA | 76 ms | 6508 KB |
01-25.txt | WA | 74 ms | 6508 KB |
01-26.txt | WA | 73 ms | 6508 KB |
01-27.txt | WA | 73 ms | 6508 KB |
01-28.txt | WA | 76 ms | 6508 KB |
01-29.txt | WA | 71 ms | 6092 KB |
01-30.txt | WA | 71 ms | 6092 KB |
01-31.txt | WA | 74 ms | 6092 KB |
01-32.txt | WA | 70 ms | 6092 KB |
01-33.txt | WA | 70 ms | 6092 KB |
01-34.txt | WA | 70 ms | 6092 KB |
01-35.txt | WA | 74 ms | 6108 KB |
01-36.txt | WA | 69 ms | 5900 KB |
01-37.txt | WA | 69 ms | 5832 KB |
01-38.txt | WA | 72 ms | 6648 KB |
01-39.txt | WA | 73 ms | 6444 KB |
01-40.txt | WA | 71 ms | 6896 KB |
01-41.txt | WA | 77 ms | 7280 KB |
01-42.txt | WA | 71 ms | 5980 KB |
01-43.txt | WA | 76 ms | 6040 KB |
01-44.txt | WA | 74 ms | 6508 KB |
01-45.txt | WA | 70 ms | 5880 KB |
01-46.txt | WA | 72 ms | 6768 KB |
01-47.txt | WA | 86 ms | 8816 KB |
01-48.txt | WA | 86 ms | 8816 KB |
01-49.txt | WA | 77 ms | 8816 KB |
01-50.txt | WA | 77 ms | 8816 KB |
01-51.txt | WA | 77 ms | 8816 KB |
01-52.txt | WA | 79 ms | 8816 KB |
01-53.txt | WA | 75 ms | 6380 KB |
01-54.txt | WA | 75 ms | 6380 KB |
01-55.txt | WA | 73 ms | 6896 KB |
01-56.txt | WA | 74 ms | 6380 KB |
01-57.txt | WA | 73 ms | 6380 KB |
01-58.txt | WA | 73 ms | 6896 KB |
01-59.txt | WA | 71 ms | 6444 KB |
01-60.txt | WA | 71 ms | 6444 KB |
01-61.txt | WA | 70 ms | 6444 KB |
01-62.txt | WA | 70 ms | 6444 KB |
01-63.txt | WA | 70 ms | 6444 KB |
01-64.txt | WA | 70 ms | 6444 KB |
01-65.txt | WA | 73 ms | 6444 KB |
01-66.txt | WA | 72 ms | 6444 KB |
01-67.txt | WA | 72 ms | 5956 KB |
01-68.txt | WA | 75 ms | 6252 KB |
01-69.txt | WA | 74 ms | 6380 KB |
01-70.txt | WA | 76 ms | 7540 KB |
01-71.txt | WA | 71 ms | 7020 KB |
01-72.txt | WA | 74 ms | 6896 KB |
01-73.txt | WA | 72 ms | 5880 KB |
01-74.txt | WA | 69 ms | 5772 KB |
01-75.txt | WA | 70 ms | 5880 KB |
01-76.txt | WA | 71 ms | 6040 KB |
01-77.txt | WA | 78 ms | 6768 KB |
01-78.txt | WA | 78 ms | 6768 KB |
01-79.txt | WA | 73 ms | 6188 KB |
01-80.txt | WA | 73 ms | 6768 KB |
01-81.txt | WA | 73 ms | 6188 KB |
01-82.txt | WA | 73 ms | 6640 KB |
01-83.txt | AC | 2 ms | 1280 KB |
01-84.txt | AC | 2 ms | 1280 KB |
01-85.txt | AC | 50 ms | 3196 KB |
01-86.txt | AC | 49 ms | 3196 KB |
01-87.txt | AC | 49 ms | 3196 KB |
01-88.txt | AC | 18 ms | 2432 KB |
01-89.txt | AC | 18 ms | 2432 KB |
01-90.txt | AC | 18 ms | 2432 KB |
sample-01.txt | AC | 2 ms | 1280 KB |
sample-02.txt | AC | 1 ms | 256 KB |