# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
921180 | Macker | 곤돌라 (IOI14_gondola) | C++17 | 19 ms | 2396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
ll mod = 1000000009;
ll power(ll n, ll k){
ll res = 1;
n %= mod;
while(k > 0){
if(k & 1) res = (res * n) % mod;
n = (n * n) % mod;
k /= 2;
}
return res;
}
int valid(int n, int inputSeq[])
{
return countReplacement(n, inputSeq) != 0;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++) {
v[i] = {gondolaSeq[i], i};
}
sort(all(v));
ll strt = -1;
for (auto &i : v) {
if(i.first <= n){
strt = (i.second - i.first + 1 + n) % n;
break;
}
}
if(strt == -1) strt = 0;
for (int i = 0; i < n; i++) {
gondolaSeq[i] = (i - strt + n) % n + 1;
}
int ls = n;
int j = 0;
for (auto &i : v) {
while(ls < i.first){
replacementSeq[j++] = gondolaSeq[i.second];
ls++;
gondolaSeq[i.second] = ls;
}
}
return j;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
vector<pair<int, int>> v(n);
for (int i = 0; i < n; i++) {
v[i] = {inputSeq[i], i};
}
sort(all(v));
for (int i = 1; i < v.size(); i++) {
if(v[i].first == v[i - 1].first) return 0;
}
ll strt = -1;
ll fin = 0;
bool m = true;
ll res = 1;
for (int j = 0; j < v.size(); j++) {
auto i = v[j];
if(i.first <= n){
if(strt == -1){
strt = (i.second - i.first + 1 + n) % n;
}
else{
if((i.second - i.first + 1 + n) % n != strt) return 0;
}
m = false;
}
else{
ll ls;
if(j == 0 || v[j - 1].first <= n){
ls = n + 1;
}
else ls = v[j - 1].first + 1;
res = (res * power(n - fin, i.first - ls)) % mod;
}
fin++;
}
if(m) res = (res * n) % mod;
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... |