Submission #422417

#TimeUsernameProblemLanguageResultExecution timeMemory
422417Andyvanh1Gondola (IOI14_gondola)C++14
55 / 100
22 ms3020 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; #define vt vector #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ ) typedef long long ll; typedef long double ld; typedef vt<int> vi; typedef pair<int,int> pii; int x[100005]; int valid(int n, int inputSeq[]){ int at = -1; rep(i,n)x[i] = inputSeq[i]; sort(x,x+n); for(int i = 1; i < n; i++){ if(x[i]==x[i-1])return 0; } for(int i = 0; i < n; i++){ if(inputSeq[i]>n){ inputSeq[i] = -1; }else{ at = i; } } if(at==-1)return 1; bool bol = true; for(int i = at; i < n; i++){ if(inputSeq[i]!=-1&&inputSeq[i]!=(inputSeq[at]+i-at-1)%n+1){ return 0; } } for(int i = 0; i < at; i++){ if(inputSeq[i]!=-1&&inputSeq[i]!=(inputSeq[at]-at+i+n-1)%n+1){ return 0; } } return 1; } bool taken[100005]; int cur[100005]; int matr[250010]; int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int Max = 0; rep(i,n){ Max = max(Max,gondolaSeq[i]); } rep(i,Max+1){ matr[i] = -1; } int at = -1; for(int i = 0; i < n; i++){ if(gondolaSeq[i]<=n){ at = i; break; } } if(at==-1){ rep(i,n){ cur[i] = i+1; } }else{ for(int i = 0; i < n; i++){ cur[i] = (gondolaSeq[at]-at+i+n-1)%n+1; if(gondolaSeq[i] <= n)taken[i] = true; } } for(int i = 0; i < n; i++){ matr[gondolaSeq[i]] = i; } for(int j = n+1; j <= Max; j++){ if(matr[j]!=-1){ replacementSeq[j-n-1] = cur[matr[j]]; cur[matr[j]] = j; taken[matr[j]] = true; }else{ for(int i = 0; i < n; i++){ if(taken[i]==false){ replacementSeq[j-n-1] = cur[i]; cur[i] = j; break; } } } } return Max-n; } int countReplacement(int n, int inputSeq[]){ return 0; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
      |                          ^
gondola.cpp:20:5: note: in expansion of macro 'rep'
   20 |     rep(i,n)x[i] = inputSeq[i];
      |     ^~~
gondola.cpp:33:10: warning: unused variable 'bol' [-Wunused-variable]
   33 |     bool bol = true;
      |          ^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:9:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
      |                          ^
gondola.cpp:54:5: note: in expansion of macro 'rep'
   54 |     rep(i,n){
      |     ^~~
gondola.cpp:9:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
      |                          ^
gondola.cpp:57:5: note: in expansion of macro 'rep'
   57 |     rep(i,Max+1){
      |     ^~~
gondola.cpp:9:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++ )
      |                          ^
gondola.cpp:68:9: note: in expansion of macro 'rep'
   68 |         rep(i,n){
      |         ^~~
#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...