# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68811 | 2018-08-18T14:33:58 Z | Vahan | 곤돌라 (IOI14_gondola) | C++17 | 28 ms | 2152 KB |
#include "gondola.h" #include<vector> #include<algorithm> #include<iostream> using namespace std; int x[200000],xx[200000]; int mod=1000000009; vector<int> g; int valid(int n, int inputSeq[]) { vector<int> v; for(int i=0;i<n;i++) xx[i]=inputSeq[i]; sort(xx,xx+n); int t=0; for(int i=1;i<n;i++) if(xx[i]==xx[i-1]) { t=1; break; } if(t==1) return 0; for(int i=0;i<n;i++) { if(inputSeq[i]<=n) { v.push_back(inputSeq[i]); x[inputSeq[i]]=i; } } t=0; for(int i=1;i<v.size();i++) { if(v[i-1]>v[i]) t++; } if(t>=2) return 0; if(t==1 && v.back()>v[0]) return 0; t=0; for(int i=1;i<v.size();i++) { if(v[i-1]<v[i]) { if(v[i]-v[i-1]!=x[v[i]]-x[v[i-1]]) { t=1; break; } } else if(v[i-1]>v[i]) { if((n-(v[i-1]-v[i]))!=x[v[i]]-x[v[i-1]]) { t=1; break; } } } if(t==1) return 0; return 1; } int binpow(int a,int b) { if(b==0) return 1; if(b%2==0) { int c=binpow(a,b/2); return (c*c)%mod; } else { int c=binpow(a,b/2); return (a*(c*c)%mod)%mod; } } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -2; } //---------------------- int countReplacement(int n, int inputSeq[]) { if(valid(n,inputSeq)==0) return 0; for(int i=0;i<n;i++) { if(inputSeq[i]>n) g.push_back(inputSeq[i]); } sort(g.begin(),g.end()); int k=g.size(); int pat=1; for(int i=0;i<g.size();i++) { int u; if(i==0) u=g[i]-n-1; else u=g[i]-g[i-1]-1; pat*=binpow(k,u); pat%=mod; k--; } if(g.size()==n) pat*=n; pat%=mod; return pat; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 564 KB | Output is correct |
4 | Correct | 3 ms | 568 KB | Output is correct |
5 | Correct | 2 ms | 568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 648 KB | Output is correct |
2 | Correct | 2 ms | 648 KB | Output is correct |
3 | Correct | 3 ms | 648 KB | Output is correct |
4 | Correct | 2 ms | 648 KB | Output is correct |
5 | Correct | 3 ms | 648 KB | Output is correct |
6 | Correct | 12 ms | 1356 KB | Output is correct |
7 | Correct | 22 ms | 1356 KB | Output is correct |
8 | Correct | 28 ms | 1992 KB | Output is correct |
9 | Correct | 9 ms | 1992 KB | Output is correct |
10 | Correct | 24 ms | 2116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2116 KB | Output is correct |
2 | Correct | 2 ms | 2116 KB | Output is correct |
3 | Correct | 2 ms | 2116 KB | Output is correct |
4 | Correct | 2 ms | 2116 KB | Output is correct |
5 | Correct | 3 ms | 2116 KB | Output is correct |
6 | Correct | 13 ms | 2116 KB | Output is correct |
7 | Correct | 23 ms | 2116 KB | Output is correct |
8 | Correct | 27 ms | 2116 KB | Output is correct |
9 | Correct | 8 ms | 2116 KB | Output is correct |
10 | Correct | 26 ms | 2152 KB | Output is correct |
11 | Correct | 2 ms | 2152 KB | Output is correct |
12 | Correct | 2 ms | 2152 KB | Output is correct |
13 | Correct | 10 ms | 2152 KB | Output is correct |
14 | Correct | 2 ms | 2152 KB | Output is correct |
15 | Correct | 26 ms | 2152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2152 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2152 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2152 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2152 KB | Output is correct |
2 | Correct | 3 ms | 2152 KB | Output is correct |
3 | Correct | 2 ms | 2152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2152 KB | Output is correct |
2 | Correct | 2 ms | 2152 KB | Output is correct |
3 | Correct | 3 ms | 2152 KB | Output is correct |
4 | Correct | 3 ms | 2152 KB | Output is correct |
5 | Correct | 3 ms | 2152 KB | Output is correct |
6 | Correct | 3 ms | 2152 KB | Output is correct |
7 | Incorrect | 2 ms | 2152 KB | Integer -130349311 violates the range [0, 1000000008] |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2152 KB | Output is correct |
2 | Correct | 3 ms | 2152 KB | Output is correct |
3 | Correct | 2 ms | 2152 KB | Output is correct |
4 | Correct | 3 ms | 2152 KB | Output is correct |
5 | Correct | 3 ms | 2152 KB | Output is correct |
6 | Correct | 3 ms | 2152 KB | Output is correct |
7 | Incorrect | 3 ms | 2152 KB | Integer -130349311 violates the range [0, 1000000008] |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2152 KB | Output is correct |
2 | Correct | 2 ms | 2152 KB | Output is correct |
3 | Correct | 3 ms | 2152 KB | Output is correct |
4 | Correct | 2 ms | 2152 KB | Output is correct |
5 | Correct | 2 ms | 2152 KB | Output is correct |
6 | Correct | 2 ms | 2152 KB | Output is correct |
7 | Incorrect | 3 ms | 2152 KB | Integer -130349311 violates the range [0, 1000000008] |
8 | Halted | 0 ms | 0 KB | - |