Submission #163477

#TimeUsernameProblemLanguageResultExecution timeMemory
163477ioaneGondola (IOI14_gondola)C++14
55 / 100
29 ms3708 KiB
#include "gondola.h"/**/ #include <bits/stdc++.h> #define LL long long #define PB push_back #define FOR(i,n) for (int i = 0; i < (n); i++) const LL N = 100005, NR = 250005; using namespace std; LL m, i, j, k, l, r, t; LL a[N], fox[NR], b[N]; bool fix[NR]; int valid(int n, int inputSeq[]){ t = 0; for ( i = 1; i <= n; ++i ){ if ( fix[inputSeq[i-1]] ) return 0; //cout << inputSeq[i-1] << " " << fix[inputSeq[i-1]] << endl; fix[inputSeq[i-1]] = 1; if ( inputSeq[i-1] <= n ){ t = inputSeq[i-1] - i; } } //if ( t == NR ) return 1; for ( i = 1; i <= n; ++i ){ j = i + t; while ( j < 1 ) j += n; while ( j > n ) j -= n; a[j] = inputSeq[i-1]; } for ( i = 1; i <= n; ++i ){ if ( a[i] <= n && a[i] != i ) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ valid(n, gondolaSeq); t = 0; for ( i = 1; i <= n; ++i ){ fox[a[i]] = i; if ( t < a[i] ){ t = a[i]; } b[i] = i; } //cout << n << " " << t << endl; for ( i = n + 1; i <= t; ++i ){ if ( !fox[i] ){ replacementSeq[i - n - 1] = b[fox[t]]; b[fox[t]] = i; } else{ replacementSeq[i - n - 1] = b[fox[i]]; b[fox[i]] = i; } m++; } return m; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; } /*/ int gondolaSequence[100001]; int replacementSequence[250001]; int main() { freopen ( "te.txt", "r", stdin); int i, n, tag; int nr; assert(scanf("%d", &tag)==1); assert(scanf("%d", &n)==1); for(i=0;i< n;i++) assert( scanf("%d", &gondolaSequence[i]) ==1); switch (tag){ case 1: case 2: case 3: printf("%d\n", valid(n, gondolaSequence)); break; case 4: case 5: case 6: nr = replacement(n, gondolaSequence, replacementSequence); printf("%d ", nr); if (nr > 0) { for (i=0; i<nr-1; i++) printf("%d ", replacementSequence[i]); printf("%d\n", replacementSequence[nr-1]); } else printf("\n"); break; case 7: case 8: case 9: case 10: printf("%d\n", countReplacement(n, gondolaSequence)); break; } return 0; } /**/

Compilation message (stderr)

gondola.cpp:114:1: warning: "/*" within comment [-Wcomment]
 /**/
#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...