Submission #494108

#TimeUsernameProblemLanguageResultExecution timeMemory
494108ahmeterenGondola (IOI14_gondola)C++17
10 / 100
11 ms1356 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; int valid(int n, int inputSeq[]) { int mn = 1e7, start = 0, it = 0; vector<int> vec(n); for(int i = 0; i < n; i++) { if(inputSeq[i] < mn) { mn = inputSeq[i]; start = i; } } for(int i = start; i < start + n; i++) { vec[it] = inputSeq[i % n]; it++; } int cur = mn; for(int i = 0; i < n; i++, cur++) { if(vec[i] > n) continue; if(vec[i] != cur) { return 0; } } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int val = 0, pos = -1; map<int, int> used; for(int i = 0; i < n; i++) { if(gondolaSeq[i] <= n) { val = gondolaSeq[i]; val = i; break; } } vector<pair<int, int>> vec; for (int i = 0; i < n; i++) { if (gondolaSeq[i] > n) { vec.push_back({gondolaSeq[i], i}); } } if(pos != -1) { for (int i = pos; i < n; i++) { gondolaSeq[i] = val++; if (val > n) { val = 1; } } for (int i = 0; i < pos; i++) { gondolaSeq[i] = val++; if (val > n) { val = 1; } } } else { for (int i = 0; i < n; i++) { gondolaSeq[i] = i + 1; } } sort(vec.begin(), vec.end()); int cur = n + 1, it = 0; for (int i = 0; i < vec.size(); i++) { while (cur <= vec[i].first) { replacementSeq[it++] = gondolaSeq[vec[i].second]; gondolaSeq[vec[i].second] = cur++; } } return it; } int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:94:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |     for (int i = 0; i < vec.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...