Submission #783218

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7832182023-07-14 18:05:56zsombor곤돌라 (IOI14_gondola)C++17
100 / 100
59 ms5896 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include "gondola.h"
using namespace std;
using ll = long long;
ll MOD = 1e9 + 9;
int valid(int n, int g[]) {
set <int> s;
for (int i = 0; i < n; i++) {
if (s.count(g[i])) return 0;
s.insert(g[i]);
}
int p = 0;
for (int i = 0; i < n; i++) if (g[i] <= n) p = (g[i] - i + n) % n;
for (int i = 0; i < n; i++) if (g[i] <= n && (g[i] - i + n) % n != p) return 0;
return 1;
}
int replacement(int n, int g[], int r[]) {
int p = 0, cnt = 0, mx = 0;
vector <int> rev(1e6 + 1, -1);
vector <int> cur(n, 0);
for (int i = 0; i < n; i++) {
if (g[i] <= n) { p = (g[i] - i + n) % n; cnt++; }
mx = max(mx, g[i]);
rev[g[i]] = i;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...