Submission #656846

#TimeUsernameProblemLanguageResultExecution timeMemory
656846happypotatoGondola (IOI14_gondola)C++17
55 / 100
42 ms5020 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { int seq[n]; set<int> s; for (int i = 0; i < n; i++) { seq[i] = (inputSeq[i] <= n ? inputSeq[i] : -1); if (s.find(inputSeq[i]) != s.end()) return 0; s.insert(inputSeq[i]); } int samemod = -1; for (int i = 0; i < n; i++) { if (seq[i] == -1) continue; int curmod = (seq[i] + n - i) % n; if (samemod == -1) samemod = curmod; else if (samemod != curmod) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector<pair<int, int>> v; v.push_back({n, -1}); int samemod = 0; for (int i = 0; i < n; i++) { if (gondolaSeq[i] <= n) { samemod = (gondolaSeq[i] + n - i) % n; } else { v.push_back({gondolaSeq[i], i}); } } sort(v.begin(), v.end()); int ptr = 0; for (int i = 1; i < int(v.size()); i++) { int ori = (v[i].second + samemod) % n; if (ori == 0) ori = n; replacementSeq[ptr++] = ori; for (int j = v[i - 1].first + 2; j <= v[i].first; j++) { replacementSeq[ptr++] = j - 1; } } return ptr; } //---------------------- int countReplacement(int n, int inputSeq[]) { }

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
   56 | }
      | ^
#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...