답안 #842808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842808 2023-09-03T11:44:20 Z Pacybwoah 곤돌라 (IOI14_gondola) C++17
55 / 100
15 ms 2388 KB
#include<algorithm>
#include<vector>
#include<utility>
#include<iostream>
#include"gondola.h"
using namespace std;

int valid(int n, int inp[])
{
    vector<int> vec;
    for(int i=0;i<n;i++) vec.push_back(inp[i]);
    sort(vec.begin(),vec.end());
    if(unique(vec.begin(),vec.end())-vec.begin()!=n) return 0;
    int first=-1;
    for(int i=0;i<n;i++){
        if(inp[i]<=n){
            first=i;
            break;
        }
    }
    if(first==-1) return 1;
    bool flag=1;
    for(int i=0;i<n;i++){
        if(inp[i]!=(inp[first]+i-first-1+n)%n+1&&inp[i]<=n){
            flag=0;
            break;
        }
    }
    return flag;
}

//----------------------

int replacement(int n, int inp[], int ans[])
{
    int first=-1,fnum;
    vector<pair<int,int> > repl;
    for(int i=0;i<n;i++){
        if(inp[i]<=n){
            first=i;
            fnum=inp[i];
        }  
        else repl.push_back(make_pair(inp[i],i));
    }
    if(first==-1) first=0,fnum=1;
    sort(repl.begin(),repl.end());
    if(repl.size()==0) return 0;
    int cnt=0,last=n+1;
    for(auto x:repl){
        ans[cnt++]=(fnum+x.second-first-1+n)%n+1;
        for(int i=last;i<x.first;i++) ans[cnt++]=i;
        last=x.first+1;
    }
    return cnt;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 6 ms 856 KB Output is correct
7 Correct 11 ms 1240 KB Output is correct
8 Correct 8 ms 1240 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 13 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 856 KB Output is correct
7 Correct 12 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 13 ms 1236 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 5 ms 1112 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 12 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 6 ms 1116 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 11 ms 1516 KB Output is correct
14 Correct 6 ms 1116 KB Output is correct
15 Correct 15 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -