# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362139 | 2021-02-01T20:18:51 Z | ogibogi2004 | Permutation Recovery (info1cup17_permutation) | C++14 | 11 ms | 492 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=70004; const ll sq=800; const ll mod=2e17+3; ll d[MAXN]; ll d1[MAXN],e; ll t[MAXN],n; ll add(ll a,ll b) { return (a+b+2*mod)%mod; } struct block { unordered_map<ll,vector<ll> >mp; ll added; }; block b[sq]; ll p[MAXN]; int main() { srand(3432);e=rand(); cin>>n; for(ll i=1;i<=n;i++) { string s; cin>>s; for(ll j=0;j<s.size();j++) { t[i]=((ll)t[i]*10+s[j]-'0')%mod; } } for(ll i=1;i<=n;i++) { d[i]=add(t[i],-t[i-1]); d1[i]=d[i]; } for(ll i=1;i<=n;i++) { b[i/sq].added=0; b[i/sq].mp[d[i]^e].push_back(i); } //for(ll i=1;i<=n;i++)cout<<d1[i]<<" "; //cout<<endl; for(ll j=1;j<=n;j++) { for(ll l=n/sq;l>=0;l--) { if(b[l].mp.count((1+b[l].added)^e)&&b[l].mp[(1+b[l].added)^e].size()>0) { ll t=b[l].mp[(1+b[l].added)^e].back(); for(ll i=l+1;i<=n/sq;i++) { b[i].added=add(b[i].added,d[t]); } for(ll i=t+1;i<=n&&i%sq!=0;i++) { d1[i]-=d[t]; } b[l].mp.clear(); p[t]=j; for(ll i=max(1ll,l*sq);i<=n&&i/sq==l;i++) { if(p[i]==0)b[i/sq].mp[d1[i]^e].push_back(i); } break; } } //for(ll i=1;i<=n;i++)cout<<d1[i]<<" "; //cout<<endl; } for(ll i=1;i<=n;i++) { cout<<p[i]<<" "; } cout<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 8 ms | 364 KB | Output is correct |
3 | Incorrect | 11 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |