Submission #67217

# Submission time Handle Problem Language Result Execution time Memory
67217 2018-08-13T16:08:05 Z MKopchev Gondola (IOI14_gondola) C++14
55 / 100
57 ms 5164 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++;
            while(prev!=k.first)
            {
                replacementSeq[ind++]=prev;
                prev++;
            }
        }
        prev=max(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,4,7};
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={};
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB Output is correct
2 Correct 2 ms 544 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 3 ms 620 KB Output is correct
6 Correct 17 ms 2412 KB Output is correct
7 Correct 54 ms 3948 KB Output is correct
8 Correct 34 ms 4204 KB Output is correct
9 Correct 11 ms 4204 KB Output is correct
10 Correct 37 ms 4844 KB Output is correct
# Verdict Execution time Memory 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 3 ms 4844 KB Output is correct
6 Correct 17 ms 4844 KB Output is correct
7 Correct 45 ms 4844 KB Output is correct
8 Correct 30 ms 4844 KB Output is correct
9 Correct 12 ms 4844 KB Output is correct
10 Correct 40 ms 4860 KB Output is correct
11 Correct 3 ms 4860 KB Output is correct
12 Correct 2 ms 4860 KB Output is correct
13 Correct 21 ms 4860 KB Output is correct
14 Correct 2 ms 4860 KB Output is correct
15 Correct 57 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4988 KB Output is correct
2 Correct 2 ms 4988 KB Output is correct
3 Correct 2 ms 4988 KB Output is correct
4 Correct 4 ms 4988 KB Output is correct
5 Correct 2 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4988 KB Output is correct
2 Correct 2 ms 4988 KB Output is correct
3 Correct 2 ms 4988 KB Output is correct
4 Correct 3 ms 4988 KB Output is correct
5 Correct 3 ms 4988 KB Output is correct
6 Correct 3 ms 4988 KB Output is correct
7 Correct 3 ms 4988 KB Output is correct
8 Correct 3 ms 4988 KB Output is correct
9 Correct 4 ms 4988 KB Output is correct
10 Correct 3 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4988 KB Output is correct
2 Correct 2 ms 4988 KB Output is correct
3 Correct 3 ms 4988 KB Output is correct
4 Correct 2 ms 4988 KB Output is correct
5 Correct 3 ms 4988 KB Output is correct
6 Correct 2 ms 4988 KB Output is correct
7 Correct 3 ms 4988 KB Output is correct
8 Correct 3 ms 4988 KB Output is correct
9 Correct 4 ms 4988 KB Output is correct
10 Correct 3 ms 4988 KB Output is correct
11 Correct 50 ms 4988 KB Output is correct
12 Correct 42 ms 5164 KB Output is correct
13 Correct 35 ms 5164 KB Output is correct
14 Correct 51 ms 5164 KB Output is correct
15 Correct 37 ms 5164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5164 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5164 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5164 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5164 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -