# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
793885 | Ronin13 | 곤돌라 (IOI14_gondola) | C++17 | 45 ms | 6012 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const ll mod = 1e9 + 9;
int valid(int n, int a[]){
vector <pii> vv;
set <int> st;
for(int i = 0; i < n; i++){
if(st.find(a[i]) != st.end())
return 0;
st.insert(a[i]);
if(a[i] <= n)
vv.pb({a[i], i});
}
sort(vv.begin(), vv.end());
for(int i = 1; i < vv.size(); i++){
int x = vv[i].s, y = vv[i - 1].s;
int dist = vv[i].f - vv[i - 1].f;
if((x - y + n) % n != dist)
return 0;
}
return 1;
}
//----------------------
int replacement(int n, int a[], int b[])
{
int c[n];
int cur = n + 1;
int ind = 0;
vector <pii> vv;
int x, y;
for(int i = 0; i < n; i++){
if(a[i] > n) vv.pb({a[i], i});
else x = a[i], y = i;
}
if(vv.size() == n){
for(int i = 0; i < n; i++) c[i] = i + 1;
}
else{
for(int i = 0; i < n; i++){
int dist = (i - y + n) % n;
c[i] = (x + dist - 1) % n + 1;
}
}
sort(vv.begin(), vv.end());
for(int i = 0; i < vv.size(); i++){
while(cur <= vv[i].f)
b[ind] = c[vv[i].s], c[vv[i].s] = cur, ind++, cur++;
}
return ind;
}
//----------------------
ll logpow(ll a, ll p){
if(p == 0)
return 1;
ll x = logpow(a, p / 2);
x *= x, x %= mod;
if(p & 1) x *= a, x %= mod;
return x;
}
int countReplacement(int n, int a[])
{
if(!valid(n, a))
return 0;
vector <int> vv;
int cnt = 0;
for(int i = 0; i < n; i++){
if(a[i] > n) cnt++, vv.pb(a[i]);
}
bool x = (cnt == n);
sort(vv.begin(), vv.end());
int last = n;
ll ans = 1;
for(int i = 0; i < vv.size(); i++){
int c = vv[i] - last - 1;
ans *= logpow(cnt, c);
cnt--;
ans %= mod;
last = vv[i];
}
if(x) ans *= (ll)n, 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... |