# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
30942 | kajebiii | Gondola (IOI14_gondola) | C++14 | 33 ms | 5792 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<double, double> pd;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF * 2;
const int MAX_N = 1e5 + 100;
int temp[MAX_N];
int valid(int n, int nr[]) {
for(int i=0; i<n; i++) temp[i] = nr[i];
int ix = -1, cnt = 0;
for(int i=0; i<n; i++) if(nr[i] >= 1 && nr[i] <= n) {
ix = i;
break;
}
sort(temp, temp+n);
for(int i=0; i+1<n; i++) if(temp[i] == temp[i+1]) return 0;
if(ix == -1) return 1;
ix = (ix + n - (nr[ix]-1)) % n;
for(int i=0; i<n; i++) {
int v = nr[(ix+i)%n];
if(v >= 1 && v <= n && v != (i+1)) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int nr[], int res[]) {
for(int i=0; i<n; i++) temp[i] = nr[i];
int ix = -1, cnt = 0;
for(int i=0; i<n; i++) if(nr[i] >= 1 && nr[i] <= n) {
ix = i;
break;
}
if(ix != -1) {
ix = (ix + n - (nr[ix]-1)) % n;
for(int i=0; i<n; i++) nr[i] = temp[(i+ix)%n];
}
// for(int i=0; i<n; i++) printf("%d ", nr[i]); puts("");
int ansL = 0;
vector<pi> ps;
for(int i=0; i<n; i++) ps.push_back(pi(nr[i], i));
sort(ALL(ps));
for(int i=0; i<n; i++) nr[i] = i+1;
int now = n;
for(int i=0; i<n; i++) {
while(now < ps[i].one) {
now++;
res[ansL++] = nr[ps[i].two];
nr[ps[i].two] = now;
}
}
return ansL;
}
//----------------------
const int MOD = 1e9 + 9;
int myTemp[MAX_N];
int countReplacement(int n, int nr[]) {
for(int i=0; i<n; i++) myTemp[i] = nr[i];
if(valid(n, myTemp) == 0) {
printf("hi!");
return 0;
}
for(int i=0; i<n; i++) temp[i] = nr[i];
int ix = -1, cnt = 0;
for(int i=0; i<n; i++) if(nr[i] >= 1 && nr[i] <= n) {
ix = i;
break;
}
if(ix != -1) {
ix = (ix + n - (nr[ix]-1)) % n;
for(int i=0; i<n; i++) nr[i] = temp[(i+ix)%n];
}
// for(int i=0; i<n; i++) printf("%d ", nr[i]); puts("");
vector<pi> ps;
for(int i=0; i<n; i++) ps.push_back(pi(nr[i], i));
sort(ALL(ps));
int unCh = n;
int now = n;
int ans = 1;
for(int i=0; i<n; i++) {
while(now < ps[i].one) {
now++;
if(now != ps[i].one)
ans = 1ll * ans * unCh % MOD;
}
unCh--;
}
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... |