Submission #259933

#TimeUsernameProblemLanguageResultExecution timeMemory
259933srjGondola (IOI14_gondola)C++14
55 / 100
96 ms9976 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { map<int,int> pos; for(int i =0;i<n;i++){ if(pos.find(inputSeq[i])!=pos.end()) return 0; pos[inputSeq[i]] = i; } int sortSeq[n]; memcpy(sortSeq,inputSeq,sizeof(sortSeq)); sort(sortSeq,sortSeq+n); if(sortSeq[0]>n) return 1; int smallval = sortSeq[0]; int cur = pos[sortSeq[0]]; for(int i =0;i<n;i++){ if(inputSeq[(cur+i)%n]!=smallval+i && inputSeq[(cur+i)%n]<=n){ // cout << smallval << endl; // cout << i << endl; return 0; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { map<int,int> pos; for(int i =0;i<n;i++){ if(pos.find(gondolaSeq[i])!=pos.end()) return 0; pos[gondolaSeq[i]] = i; } int sortSeq[n]; map<int,int> what; memcpy(sortSeq,gondolaSeq,sizeof(sortSeq)); sort(sortSeq,sortSeq+n); int pos1 = 0; if(sortSeq[0]<=n){ pos1 = (n+pos[sortSeq[0]]-sortSeq[0]+1)%n; } what[pos1] = 1; pos[1] = pos1; for(int i =2;i<=n;i++){ pos[i] = (n+pos1+i-1)%n; what[pos[i]] = i; } int nxt = n+1; int ans = sortSeq[n-1] - nxt+1; int j =0; for(int i =0;i<n;i++){ if(sortSeq[i]>n){ int where = pos[sortSeq[i]]; int prev = what[where]; while(prev!=sortSeq[i]){ replacementSeq[j] = prev; prev=nxt; nxt++; j++; } what[where] = prev; } } return ans; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(pos.find(inputSeq[i])!=pos.end())
     ^~
gondola.cpp:11:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      pos[inputSeq[i]] = i;
      ^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:36:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(pos.find(gondolaSeq[i])!=pos.end())
     ^~
gondola.cpp:38:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      pos[gondolaSeq[i]] = i;
      ^~~
#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...