제출 #391914

#제출 시각아이디문제언어결과실행 시간메모리
391914Aldas25곤돌라 (IOI14_gondola)C++14
55 / 100
31 ms4284 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define f first #define s second #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<int> vi; int valid(int n, int inputSeq[]) { FOR(i, 0, n-1) inputSeq[i]--; unordered_set<int> cont; FOR(i, 0, n-1) cont.insert(inputSeq[i]); if ((int)cont.size() < n) return false; int ch = -1; FOR(i, 0, n-1) { if (inputSeq[i] >= n) continue; ch = i; break; } if (ch == -1) return true; FOR(i, 0, n-1) { int id = (ch+i)%n; if (inputSeq[id] >= n) continue; int shouldBe = (inputSeq[ch]+i)%n; if (inputSeq[id] != shouldBe) return false; } return true; } //---------------------- int replacement(int n, int inputSeq[], int replacementSeq[]) { FOR(i, 0, n-1) inputSeq[i]--; int l = 0; int ch = 0; FOR(i, 0, n-1) { if (inputSeq[i] >= n) continue; ch = i; break; } int cur[n]; cur[ch] = (inputSeq[ch] < n ? inputSeq[ch] : 0); FOR(i, 0, n-1) { int id = (ch+i)%n; int shouldBe = (cur[ch]+i)%n; cur[id] = shouldBe; } vii seq; FOR(i, 0, n-1) { seq.pb({inputSeq[i], i}); } sort(seq.begin(), seq.end()); int crAdd = n; for (auto p : seq) { int id = p.s; while (cur[id] < inputSeq[id]) { replacementSeq[l] = cur[id]+1; cur[id] = crAdd; crAdd++; l++; } } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...