# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
589129 | FatihSolak | 곤돌라 (IOI14_gondola) | C++17 | 111 ms | 10496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]){
set<int> s;
map<int,int> pos;
for(int i = 0;i<n;i++){
s.insert(inputSeq[i]);
pos[inputSeq[i]] = i;
}
if(s.size() != n)return 0;
int num = *s.begin() + 1;
while(num <= n){
if(s.count(num) && pos[num] != (pos[*s.begin()] + num - *s.begin())%n){
return 0;
}
num++;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int pos_mini = 0;
int maxi = 0;
for(int i = 0;i<n;i++){
if(gondolaSeq[i] < gondolaSeq[pos_mini]){
pos_mini = i;
}
maxi = max(maxi,gondolaSeq[i]);
}
for(int i = 0;i<n;i++){
if(gondolaSeq[i] <= n){
pos_mini = (i - gondolaSeq[i] + 1 + n)%n;
}
}
int tmp[n];
map<int,int> mp;
for(int i = 0;i<n;i++)tmp[i] = gondolaSeq[i];
for(int i = 0;i<n;i++){
gondolaSeq[i] = tmp[(pos_mini + i)%n];
mp[gondolaSeq[i]] = i + 1;
//cout << gondolaSeq[i] << " ";
}
//cout << endl;
for(int i = n+1;i<=maxi;i++){
if(mp[i]){
replacementSeq[i - n - 1] = mp[i];
}
else{
replacementSeq[i - n - 1] = mp[maxi];
mp[maxi] = i;
}
}
return maxi - n;
}
//----------------------
const int mod = 1e9 + 9;
int countReplacement(int n, int gondolaSeq[]){
if(!valid(n,gondolaSeq))return 0;
int pos_mini = 0;
int maxi = 0;
for(int i = 0;i<n;i++){
if(gondolaSeq[i] < gondolaSeq[pos_mini]){
pos_mini = i;
}
maxi = max(maxi,gondolaSeq[i]);
}
for(int i = 0;i<n;i++){
if(gondolaSeq[i] <= n){
pos_mini = (i - gondolaSeq[i] + 1 + n)%n;
}
}
int tmp[n];
map<int,int> mp;
for(int i = 0;i<n;i++)tmp[i] = gondolaSeq[i];
for(int i = 0;i<n;i++){
gondolaSeq[i] = tmp[(pos_mini + i)%n];
mp[gondolaSeq[i]] = i + 1;
//cout << gondolaSeq[i] << " ";
}
//cout << endl;
int unfixed = 0;
for(int i = 0;i<n;i++){
if(gondolaSeq[i] > n)unfixed++;
}
int ret = 1;
if(unfixed == n){
for(int i = 1;i<=n;i++){
ret = (long long)ret * i %mod;
}
}
for(int i = n+1;i<=maxi;i++){
if(mp[i]){
unfixed--;
}
else{
ret = (long long)ret * unfixed % mod;
}
}
return ret;
}
컴파일 시 표준 에러 (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... |