# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1001344 | ZeroCool | 곤돌라 (IOI14_gondola) | C++14 | 40 ms | 6488 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
int valid(int n, int A[]){
int B[n];
int p;
set<int> s;
for(int i = 0;i < n;i++)s.insert(A[i]);
if(s.size() < n)return 0;
for(int i = 0;i< n;i++){
if(A[i] <= n){
p = i;
B[i] = A[i];
break;
}
}
for(int i = p + 1;i < n;i++){
B[i] = B[i-1] + 1;
}
for(int i = p - 1;i >= 0;i--){
B[i] = B[i + 1] - 1;
}
for(int i = 0;i < n;i ++){
if(B[i] > n) B[i] -= n;
if(B[i] <= 0) B[i] += n;
}
for(int i = 0;i<n;i++){
if(A[i] > n)continue;
if(A[i] != B[i])return 0;
}
return 1;
}
//----------------------
int replacement(int n, int A[], int ans[]){
int o = 0;
for(int i = 0;i < n;i++){
if(A[i] > n)o++;
}
vector<ar<int, 2> > v;
if(o == n){
for(int i = 0;i < n;i++)v.push_back({A[i], i + 1});
}else{
int B[n];
int p;
for(int i = 0;i< n;i++){
if(A[i] <= n){
p = i;
B[i] = A[i];
break;
}
}
for(int i = p + 1;i < n;i++){
B[i] = B[i-1] + 1;
}
for(int i = p - 1;i >= 0;i--){
B[i] = B[i + 1] - 1;
}
for(int i = 0;i < n;i ++){
if(B[i] > n) B[i] -= n;
if(B[i] <= 0) B[i] += n;
}
for(int i = 0;i < n;i++){
if(A[i] > n)v.push_back({A[i], B[i]});
}
}
sort(v.begin(), v.end());
int c = n + 1;
int cnt = 0;
for(auto [x, i]: v){
ans[cnt++] = i;
while(c != x){
ans[cnt++] = c++;
}
c++;
}
return cnt;
}
//----------------------
const int MOD = 1e9 + 9;
ll P(ll a,ll b){
ll ans = 1;
while(b){
if(b & 1)ans = (ans * a) % MOD;
a = (a * a) % MOD;
b /= 2;
}
return ans;
}
int countReplacement(int n, int A[]){
if(!valid(n, A))return 0;
ll ans = 1;
vector<int> v;
for(int i = 0;i < n;i++){
if(A[i] > n)v.push_back(A[i]);
}
if(v.empty())return 1;
sort(v.begin(), v.end());
int m = v.size();
ll c = n + 1;
for(int i = 0;i < m;i++){
int e = v[i] - c;
if(m - i == n)e++;
ans = (ans * P(m - i, e)) % MOD;
c = v[i] + 1;
}
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... |