답안 #67215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67215 2018-08-13T16:02:31 Z MKopchev 곤돌라 (IOI14_gondola) C++14
35 / 100
75 ms 6344 KB
#include<bits/stdc++.h>
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[])
{
    set<int> uniq={};
    for(int i=0;i<n;i++)
        uniq.insert(inputSeq[i]);
    if(uniq.size()!=n)return 0;
    int mini=0;
    for(int i=1;i<n;i++)
        if(inputSeq[mini]>inputSeq[i])mini=i;
    int ind=(mini+1)%n;
    int value=-1;
    int target=inputSeq[mini];
    while(ind!=mini)
    {
        value=inputSeq[ind];
        target++;
        if(value<target)return 0;
        if(value<=n&&target<=n)
        {
            if(value!=target)return 0;
        }
        ind=(ind+1)%n;
    }
    return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int mini=0;
    for(int i=1;i<n;i++)
        if(gondolaSeq[mini]>gondolaSeq[i])mini=i;
        map<int/*number you are aiming at*/,int/*where you begin*/> start={};
    if(gondolaSeq[mini]>n)
    {
        for(int i=0;i<n;i++)
            start[gondolaSeq[i]]=i+1;
    }
    else
    {
        int value=gondolaSeq[mini],t=0;
        for(int i=mini;i!=mini||t==0;i=(i+1)%n)
        {
            start[gondolaSeq[i]]=value;
            value++;
            if(value>n)value=1;
            t++;
        }
    }
    int prev=n,ind=0;
    //for(auto k:start)cout<<k.first<<" "<<k.second<<endl;
    for(auto k:start)
    {
        if(k.first!=k.second)
        {
            replacementSeq[ind++]=k.second;
            prev=max(prev,k.second);
            prev++;
            while(prev!=k.first)
            {
                replacementSeq[ind++]=prev;
                prev++;
            }
        }
        prev=k.first;
    }

    //cout<<ind<<" : ";for(int i=0;i<ind;i++)cout<<replacementSeq[i]<<" ";cout<<endl;
    return ind;
}
int countReplacement(int n, int inputSeq[])
{
    return -1;
}
/*
int n=3;
int v[]={1,2,10};
int arr[7];
int main()
{
    cout<<valid(n,v)<<endl;
    cout<<replacement(n,v,arr)<<endl;
}
*/

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(uniq.size()!=n)return 0;
        ~~~~~~~~~~~^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:32:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=1;i<n;i++)
     ^~~
gondola.cpp:34:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         map<int/*number you are aiming at*/,int/*where you begin*/> start={};
         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 4 ms 432 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 3 ms 540 KB Output is correct
5 Correct 3 ms 584 KB Output is correct
6 Correct 19 ms 2504 KB Output is correct
7 Correct 51 ms 3912 KB Output is correct
8 Correct 30 ms 4168 KB Output is correct
9 Correct 12 ms 4168 KB Output is correct
10 Correct 37 ms 4844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4844 KB Output is correct
2 Correct 3 ms 4844 KB Output is correct
3 Correct 3 ms 4844 KB Output is correct
4 Correct 3 ms 4844 KB Output is correct
5 Correct 2 ms 4844 KB Output is correct
6 Correct 23 ms 4844 KB Output is correct
7 Correct 43 ms 4844 KB Output is correct
8 Correct 41 ms 4844 KB Output is correct
9 Correct 15 ms 4844 KB Output is correct
10 Correct 38 ms 4860 KB Output is correct
11 Correct 3 ms 4860 KB Output is correct
12 Correct 3 ms 4860 KB Output is correct
13 Correct 27 ms 4860 KB Output is correct
14 Correct 2 ms 4860 KB Output is correct
15 Correct 75 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 2 ms 4992 KB Output is correct
4 Correct 2 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 2 ms 4992 KB Output is correct
4 Correct 2 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 2 ms 4992 KB Output is correct
7 Correct 3 ms 4992 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4992 KB Output is correct
10 Correct 4 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 2 ms 4992 KB Output is correct
4 Correct 2 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 3 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 3 ms 4992 KB Output is correct
9 Correct 4 ms 4992 KB Output is correct
10 Correct 3 ms 4992 KB Output is correct
11 Correct 42 ms 5132 KB Output is correct
12 Correct 55 ms 6344 KB Output is correct
13 Incorrect 39 ms 6344 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -