# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
414164 | dxz05 | 곤돌라 (IOI14_gondola) | C++14 | 1082 ms | 6244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 2e2;
int a[MAXN];
int valid(int n, int inputSeq[]){
for (int i = 0; i < 3 * n; i++) a[i] = inputSeq[i % n];
set<int> s;
for (int i = 0; i < n; i++) s.insert(a[i]);
if (s.size() != n) return 0;
int ind = -1;
for (int i = n; i < 2 * n; i++){
if (a[i] <= n){
ind = i;
break;
}
}
if (ind == -1) return 1;
for (int i = ind - a[ind] + 1; i <= ind - a[ind] + n; i++){
if (a[i] > n) continue;
if (a[i] - a[ind] != i - ind) return 0;
}
return 1;
}
//----------------------
int orig[MAXN];
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
for (int i = 0; i < n; i++){
a[i] = gondolaSeq[i];
orig[i] = i + 1;
}
for (int i = 0; i < n; i++){
if (a[i] <= n){
int ind = 1;
for (int j = i - a[i] + 1; j <= i - a[i] + n; j++){
orig[(j + n) % n] = ind++;
}
break;
}
}
set<pair<int, int>> s;
for (int i = 0; i < n; i++){
s.insert(make_pair(a[i], orig[i]));
}
int last = n;
int sz = 0;
while (!s.empty()){
int cur = s.begin()->second, need = s.begin()->first;
s.erase(s.begin());
if (cur == need) continue;
replacementSeq[sz++] = cur;
last++;
while (last < need){
replacementSeq[sz++] = last;
last++;
}
}
return sz;
}
//----------------------
int countReplacement(int n, int inputSeq[]){
if (valid(n, inputSeq) == 0) return 0;
for (int i = 0; i < n; i++){
a[i + 1] = inputSeq[i];
}
sort(a + 1, a + n + 1);
if (a[n] == n) return 1;
int j = 1;
long long ans = 1, MOD = 1e9 + 9;
if (a[1] > n) ans = n;
for (int x = n + 1; x <= a[n]; x++){
while (j <= n && a[j] < x) j++;
if (a[j] == x) continue;
ans *= n - j + 1;
ans %= MOD;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |