Submission #232097

#TimeUsernameProblemLanguageResultExecution timeMemory
232097spdskatrGondola (IOI14_gondola)C++14
45 / 100
31 ms2548 KiB
#include "gondola.h" #include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <utility> #define fi first #define se second using namespace std; typedef pair<int, int> pii; int valid(int n, int inputSeq[]) { int offset = -1; for (int i = 0; i < n; i++) { if (inputSeq[i] <= n) { offset = (i - inputSeq[i] + 1 + n) % n; break; } } if (offset == -1) return 1; else { for (int i = 0; i < n; i++) { int ind = (offset+i) % n; if (inputSeq[ind] < n && inputSeq[ind] != i+1) return 0; } } return 1; } //---------------------- namespace T2 { int original[100005], cnt; vector<pii> elems; int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int offset = -1; for (int i = 0; i < n; i++) { if (gondolaSeq[i] <= n) { offset = (i - gondolaSeq[i] + 1 + n) % n; break; } } if (offset == -1) { for (int i = 0; i < n; i++) original[i] = i+1; } else { for (int i = 0; i < n; i++) { original[(offset+i)%n] = i+1; } } for (int i = 0; i < n; i++) { if (gondolaSeq[i] > n) { elems.push_back({ gondolaSeq[i], i }); } } sort(elems.begin(), elems.end()); int cur = n+1; for (int i = 0; i < elems.size(); i++) { while (elems[i].fi >= cur) { replacementSeq[cnt++] = original[elems[i].se]; original[elems[i].se] = cur++; } } return cnt; } } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return T2::replacement(n, gondolaSeq, replacementSeq); } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int T2::replacement(int, int*, int*)':
gondola.cpp:58:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < elems.size(); 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...