# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428406 | 2021-06-15T11:26:24 Z | Amylopectin | Gondola (IOI14_gondola) | C++14 | 30 ms | 2980 KB |
#include <iostream> #include <stdio.h> #include <algorithm> #include "gondola.h" //#include "grader.cpp" using namespace std; const long long mxn = 2e6 + 10,mo = 1e9 + 9; struct we { long long stn,thn; }; bool cmp(const struct we &l,const struct we &r) { return l.thn < r.thn; } struct we so[mxn] = {}; int u[mxn] = {}; int valid(int n, int inp[]) { long long i,j,m,stp = -1,of = 0; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } } if(stp >= 0 && inp[i] <= n) { if((stp + inp[i] - 1) % n != i) { of = 1; break; } } } for(i=0; i<n; i++) { if(u[inp[i]] == 1) { of = 1; break; } else { u[inp[i]] = 1; } } if(of == 0) { return 1; } return 0; } int replacement(int n, int inp[], int ans[]) { long long i,j,ru = 0,stp = -1,fr,ba,rua = 0; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } break; } } if(stp == -1) { stp = 0; } for(i=0; i<n; i++) { if(inp[i] > n) { so[ru] = {(i + n - stp) % n + 1,inp[i]}; ru ++; } } sort(so,so+ru,cmp); fr = 0; ba = 0; // while(ba < ru) // { // } for(i=n+1; i<=so[ru-1].thn; i++) { if(i == so[fr].thn) { ans[rua] = so[fr].stn; rua ++; fr ++; // if(ba < fr) // { // ba = fr; // } } else { ans[rua] = so[fr].stn; so[fr].stn = i; rua ++; } } return rua; } int countReplacement(int n, int inp[]) { long long i,j,m,stp = -1,of = 0,ans = 1,be,ru = 0,off = 0,cva,cdif,fva; for(i=0; i<n; i++) { if(stp == -1 && inp[i] <= n) { stp = i - inp[i] + 1; if(stp < 0) { stp += n; } } if(stp >= 0 && inp[i] <= n) { if((stp + inp[i] - 1) % n != i) { of = 1; break; } } } // for(i=0; i<n; i++) // { // if(u[inp[i]] == 1) // { // of = 1; // break; // } // else // { // u[inp[i]] = 1; // } // } if(of == 1) { return 0; } if(stp == -1) { off = 1; ans *= n; stp = 0; } for(i=0; i<n; i++) { if(inp[i] > n) { so[ru] = {(i + n - stp) % n + 1,inp[i]}; ru ++; } } sort(so,so+ru,cmp); be = n; for(i=0; i<ru; i++) { if(so[i].thn == be) { return 0; } cdif = so[i].thn - be - 1; cva = ru-i; j = 0; while(1) { fva = (1 << j) & cdif; if(fva > 0) { ans *= cva; ans %= mo; } j ++; cva = cva * cva; cva %= mo; fva = (1 << j); if(fva > cdif) { break; } } // for(j=be+1; j<so[i].thn; j++) // { // ans *= ru-i; // ans %= mo; // } be = so[i].thn; } return ans; // return -3; } //int main() //{ // // return 0; //}
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 5 ms | 588 KB | Output is correct |
7 | Correct | 11 ms | 972 KB | Output is correct |
8 | Correct | 9 ms | 844 KB | Output is correct |
9 | Correct | 4 ms | 460 KB | Output is correct |
10 | Correct | 10 ms | 864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 7 ms | 588 KB | Output is correct |
7 | Correct | 13 ms | 972 KB | Output is correct |
8 | Correct | 9 ms | 776 KB | Output is correct |
9 | Correct | 3 ms | 460 KB | Output is correct |
10 | Correct | 11 ms | 844 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 6 ms | 1484 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 12 ms | 1472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 304 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 308 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 10 ms | 1012 KB | Output is correct |
12 | Correct | 14 ms | 1100 KB | Output is correct |
13 | Correct | 18 ms | 1740 KB | Output is correct |
14 | Correct | 9 ms | 972 KB | Output is correct |
15 | Correct | 23 ms | 2400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 300 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 23 ms | 1916 KB | Output is correct |
10 | Correct | 16 ms | 1484 KB | Output is correct |
11 | Correct | 7 ms | 904 KB | Output is correct |
12 | Correct | 8 ms | 972 KB | Output is correct |
13 | Correct | 3 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 19 ms | 1944 KB | Output is correct |
10 | Correct | 14 ms | 1484 KB | Output is correct |
11 | Correct | 6 ms | 828 KB | Output is correct |
12 | Correct | 7 ms | 972 KB | Output is correct |
13 | Correct | 3 ms | 588 KB | Output is correct |
14 | Correct | 30 ms | 2368 KB | Output is correct |
15 | Correct | 26 ms | 2980 KB | Output is correct |
16 | Correct | 5 ms | 716 KB | Output is correct |
17 | Correct | 18 ms | 2180 KB | Output is correct |
18 | Correct | 11 ms | 1328 KB | Output is correct |