# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
166622 | TAISA_ | 곤돌라 (IOI14_gondola) | C++14 | 92 ms | 6096 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
int valid(int n, int inputSeq[]) {
int b = -1;
set<int> st;
for (int i = 0; i < n; i++) {
if (st.count(inputSeq[i])) {
return 0;
}
st.insert(inputSeq[i]);
if (inputSeq[i] <= n) {
if (b == -1) {
b = inputSeq[i];
} else {
if (b == n) {
if (inputSeq[i] != 1) {
return 0;
}
b = 1;
} else {
if (inputSeq[i] != b + 1) {
return 0;
}
b++;
}
}
} else {
if (b != -1) {
if (b == n) {
b = 1;
} else {
b++;
}
}
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int ma = -1;
vector<int> co(250010), idx(n);
int id = 0;
int b = -1;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
if (b == -1) {
b = gondolaSeq[i];
for (int j = i; j < n; j++) {
idx[j] = b;
b++;
if (b == n + 1) {
b = 1;
}
}
for (int j = 0; j < i; j++) {
idx[j] = b;
b++;
if (b == n + 1) {
b = 1;
}
}
break;
}
}
}
if (b == -1) {
for (int i = 0; i < n; i++) {
idx[i] = i + 1;
}
}
vector<P> v;
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] > n) {
ma = max(ma, gondolaSeq[i]);
v.push_back(P(gondolaSeq[i], i));
co[gondolaSeq[i]] = 1;
}
}
sort(v.begin(), v.end());
int t = n + 1;
for (int i = 0; i < v.size(); i++) {
replacementSeq[id] = idx[v[i].second];
id++;
for (int j = t; j < gondolaSeq[v[i].second]; j++) {
replacementSeq[id] = j;
id++;
}
t = gondolaSeq[v[i].second] + 1;
}
return id;
}
//----------------------
const ll MOD = 1000000009LL;
ll mpow(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) {
res *= x;
res %= MOD;
}
x *= x;
x %= MOD;
n >>= 1;
}
return res;
}
int countReplacement(int n, int inputSeq[]) {
if (!valid(n, inputSeq)) {
return 0;
}
ll b = -1;
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n) {
if (b == -1) {
b = 1;
break;
}
}
}
ll res = 1;
if (b == -1) {
res *= n;
}
vector<ll> v;
for (int i = 0; i < n; i++) {
if (inputSeq[i] > n) {
v.push_back(inputSeq[i]);
}
}
sort(v.begin(), v.end());
ll co = v.size();
b = n + 1;
for (int i = 0; i < v.size(); i++) {
res *= mpow(co, v[i] - b);
res %= MOD;
--co;
b = v[i] + 1;
}
return res;
}
컴파일 시 표준 에러 (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... |