# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
30341 | kavun | 곤돌라 (IOI14_gondola) | C++14 | 166 ms | 7876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 9;
int power(int x, int k) {
int res = 1;
while(k) {
if(k & 1)
res = (ll) res * x % mod;
x = (ll) x * x % mod;
k >>= 1;
}
return res;
}
int valid(int n, int inputSeq[])
{
int index = -1, val = -1;
for(int i = 0; i < n; i++)
if(inputSeq[i] <= n)
{
index = i;
val = inputSeq[i];
break;
}
for(int i = index + 1; i < n; i++)
if(inputSeq[i] <= n && (val + i - index - 1) % n + 1 != inputSeq[i])
return 0;
set<int> s;
for(int i = 0; i < n; i++)
s.insert(inputSeq[i]);
if(s.size() == n)
return 1;
else
return 0;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
if(!valid(n,inputSeq))
return 0;
int ans = 1;
set<int> rep;
for(int i = 0; i < n; i++)
if(inputSeq[i] > n)
rep.insert(inputSeq[i]);
int before = n, cnt = 0;
for(set<int>::iterator it = rep.begin(); it != rep.end(); it++)
{
int x = *it;
ans = (ll) ans * power(rep.size() - cnt, x - before - 1) % mod;
before = x;
cnt++;
}
sort(inputSeq, inputSeq+n);
if(inputSeq[0] > n)
ans = (ll)ans * n % 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... |