Submission #1080335

#TimeUsernameProblemLanguageResultExecution timeMemory
1080335modwweGondola (IOI14_gondola)C++17
100 / 100
47 ms8664 KiB
#include "gondola.h" #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while(c<'0'||c>'9') { c=getchar_unlocked(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar_unlocked(); } return x; } void phongbeo(); const int inf=1e9; const int mod2=1e9+9; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid; int i,s10,s12; long long s3; int kk; int el=29; int a[100001]; int b[250001]; vector<int> v; set<int> s; int valid(int n, int inputSeq[]) { for(int i=1; i<=n; i++) a[i]=inputSeq[i-1]; for(int i=1; i<=n; i++) { if(s.find(a[i])!=s.end()) return 0; if(a[i]<=n) { s2=i; } s.insert(a[i]); } if(s2==0) return 1; for(int i=1; i<=n; i++) { if(a[i]<=n) { s3=a[s2]+i-s2; if(s3<=0) s3+=n; if(s3>n )s3-=n; if(s3!=a[i]) { ///cout<<s3<<" "<<i<<" "<<s2,down return 0; } } } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { for(int i=1; i<=n; i++) a[i]=gondolaSeq[i-1]; for(int i=1; i<=n; i++) if(a[i]<=n) s4=i; for(int i=1; i<=n; i++) { s3=a[s4]+i-s4; if(s3<=0) s3+=n; if(s3>n )s3-=n; b[a[i]]=s3,s2=max(s2,a[i]); } s3=n+1; dem=-1; for(int i=n+1; i<=s2; i++) { if(b[i]) { replacementSeq[++dem]=b[i]; for(int j=s3; j<i; j++) replacementSeq[++dem]=j; s3=i+1; } } return dem+1; } long long ipow(int x, int p) { long long ret = 1, piv = x; while(p) { if(p&1) ret *= piv; piv *= piv; ret %= mod2; piv %= mod2; p >>= 1; } return ret; } int countReplacement(int n, int inputSeq[]) { for(int i=1; i<=n; i++) a[i]=inputSeq[i-1]; for(int i=1; i<=n; i++) { if(s.find(a[i])!=s.end()) return 0; if(a[i]<=n) { s2=i; } s.insert(a[i]); } if(s2!=0) { for(int i=1; i<=n; i++) { if(a[i]<=n) { s3=a[s2]+i-s2; if(s3<=0) s3+=n; if(s3>n )s3-=n; if(s3!=a[i]) { ///cout<<s3<<" "<<i<<" "<<s2,down return 0; } } } } for(int i=1; i<=n; i++) { if(a[i]>n) v.pb(a[i]); } sort(v.begin(),v.end()); s2=n; s3=1; dem=v.size(); if(dem==n)s3=n; for(auto x:v) { s3=(s3*ipow(dem,x-s2-1))%mod2; dem--; s2=x; } return s3; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...