# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
297994 | Plurm | 곤돌라 (IOI14_gondola) | C++11 | 27 ms | 3192 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <cstdio>
#include <cstring>
bool flag = false;
int valid(int n, int inputSeq[])
{
int offs = 0;
for(int i = 0; i < n; i++){
if(inputSeq[i] <= n) offs = (n+i-inputSeq[i]+1) % n;
}
for(int i = 0; i < n; i++){
if(flag){
if(inputSeq[(i+offs) % n] <= n && inputSeq[(i+offs) % n] != i+1) return 0;
}else{
if(inputSeq[(i+offs) % n] != i+1) return 0;
}
}
return 1;
}
//----------------------
int expect[250005];
int initSeq[100005];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int offs = 0;
int dummy = 0;
int mx = -1;
memset(expect, -1, sizeof(expect));
for(int i = 0; i < n; i++){
if(gondolaSeq[i] <= n) offs = (n+i-gondolaSeq[i]+1) % n;
else expect[gondolaSeq[i]] = i;
if(gondolaSeq[i] > mx){
mx = gondolaSeq[i];
dummy = i;
}
}
for(int i = 0; i < n; i++){
initSeq[(i+offs) % n] = i+1;
}
int rpidx = 0;
for(int i = n+1; i <= mx; i++){
if(expect[i] == -1){
replacementSeq[rpidx++] = initSeq[dummy];
initSeq[dummy] = i;
}else{
replacementSeq[rpidx++] = initSeq[expect[i]];
initSeq[expect[i]] = i;
}
}
return rpidx;
}
//----------------------
const int MOD = 1e9+9;
int countReplacement(int n, int inputSeq[])
{
flag = true;
if(!valid(n, inputSeq)) return 0;
flag = false;
int offs = -1;
int dummy = 0;
int mx = -1;
int dcnt = 0;
memset(expect, -1, sizeof(expect));
for(int i = 0; i < n; i++){
if(inputSeq[i] <= n) offs = (n+i-inputSeq[i]+1) % n;
else expect[inputSeq[i]] = i;
if(inputSeq[i] > mx){
mx = inputSeq[i];
dummy = i;
}
}
int ans = offs == -1 ? n : 1;
if(offs == -1) offs = 0;
for(int i = 0; i < n; i++){
initSeq[(i+offs) % n] = i+1;
}
for(int i = 0; i < n; i++){
if(initSeq[i] == inputSeq[i]) dcnt++;
}
for(int i = n+1; i <= mx; i++){
if(expect[i] == -1){
ans = 1ll * ans * (n-dcnt) % MOD;
}else{
initSeq[expect[i]] = i;
dcnt++;
}
}
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... |