Submission #1018817

#TimeUsernameProblemLanguageResultExecution timeMemory
1018817amine_arouaGondola (IOI14_gondola)C++17
35 / 100
1096 ms5132 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { bool acc = 1; set<int> s; for(int i = 0 ; i< n ; i++) { inputSeq[i]--; s.insert(inputSeq[i]); if(inputSeq[i] < n) acc = 0; } if((int)s.size() != n) return 0; if(acc) return 1; for(int i = 0 ; i < n ; i++) { if(inputSeq[i] < n) { int j = i; int ok = 1; do { j = (j + 1) % n; if (inputSeq[j] >= n) continue; if (inputSeq[j] != (inputSeq[i] + j - i + n) % n) { ok = 0; break; } } while(i != j); return ok; } } } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { set<pair<int, int>> s; vector<int> perm(n); for(int i = 0 ; i < n ; i++) perm[i] = i; for(int i = 0 ; i < n ; i++) { gondolaSeq[i]--; if(gondolaSeq[i] >= n) s.insert({gondolaSeq[i] , i}); else { perm[i] = gondolaSeq[i]; int j = i; do { j = (j + 1)%n; perm[j] = (gondolaSeq[i] + j - i + n)%n; } while (i != j); } } vector<int> rep; int cnt = n - 1; while (!s.empty()) { auto it = s.begin(); int i = it->second; int x = it->first; int last = perm[i]; while (cnt < x) { cnt++; rep.push_back(last); last = cnt; } s.erase(s.begin()); } for(int i = 0 ; i < (int)rep.size() ; i++) replacementSeq[i] = rep[i] + 1; return (int)rep.size(); } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:7:14: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     set<int> s;
      |              ^
#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...