# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30315 | 2017-07-23T08:39:06 Z | Nikefor | Gondola (IOI14_gondola) | C++ | 16 ms | 3396 KB |
#include "gondola.h" #include <vector> #include <algorithm> #define mod 1000000009 using namespace std; long long us(int x, int y) { if(y==0) return 1; if(y==1) return x%mod; if(y&1) return (us(x,y>>1) + us(x, (y>>1)+1))%mod; return (us(x, y>>1)*2)%mod; } int valid(int n, int inputSeq[]) { vector<int> used; for (int i = 0; i < n-1; ++i) { used.push_back(inputSeq[i]); if(inputSeq[i]<=n and inputSeq[i+1]<=n and inputSeq[i+1]!=1 and inputSeq[i]>inputSeq[i+1]) return 0; } sort(used.begin(), used.end()); for(int i=0; i<used.size()-1; i++) if(used[i]==used[i+1]) return 0; return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -2; } //---------------------- int countReplacement(int n, int inputSeq[]) { int res = 1, ctr=0; if(!valid(n, inputSeq)) return -1; bool flag = true; vector<int> v; for (int i = 0; i < n; ++i) { if(inputSeq[i]>n) flag = false; if(i!=n-1 and inputSeq[i+1] != (inputSeq[i]+1) and inputSeq[i+1]!=1) flag = false; if(inputSeq[i]>n) { ctr++; v.push_back(inputSeq[i]); } } sort(v.begin(), v.end()); if(flag) return 1; int last = n+1; for(int i= 0; i<v.size(); i++) { res*= us(v[i]-last, v.size()-i); last = v[i]+1; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2544 KB | Output is correct |
2 | Correct | 0 ms | 2544 KB | Output is correct |
3 | Correct | 0 ms | 2544 KB | Output is correct |
4 | Correct | 0 ms | 2544 KB | Output is correct |
5 | Correct | 0 ms | 2544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2544 KB | Output is correct |
2 | Correct | 0 ms | 2544 KB | Output is correct |
3 | Correct | 0 ms | 2544 KB | Output is correct |
4 | Correct | 0 ms | 2544 KB | Output is correct |
5 | Correct | 0 ms | 2544 KB | Output is correct |
6 | Correct | 9 ms | 3012 KB | Output is correct |
7 | Correct | 6 ms | 2544 KB | Output is correct |
8 | Correct | 13 ms | 3396 KB | Output is correct |
9 | Correct | 3 ms | 2816 KB | Output is correct |
10 | Correct | 16 ms | 3396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2544 KB | Output is correct |
2 | Correct | 0 ms | 2544 KB | Output is correct |
3 | Correct | 0 ms | 2544 KB | Output is correct |
4 | Correct | 0 ms | 2544 KB | Output is correct |
5 | Correct | 0 ms | 2544 KB | Output is correct |
6 | Correct | 6 ms | 3012 KB | Output is correct |
7 | Correct | 13 ms | 2544 KB | Output is correct |
8 | Correct | 13 ms | 3396 KB | Output is correct |
9 | Correct | 3 ms | 2816 KB | Output is correct |
10 | Correct | 9 ms | 3396 KB | Output is correct |
11 | Incorrect | 0 ms | 2544 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Integer -2 violates the range [0, 350000] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |