Submission #1032884

# Submission time Handle Problem Language Result Execution time Memory
1032884 2024-07-24T10:23:37 Z vjudge1 Gondola (IOI14_gondola) C++17
55 / 100
15 ms 6256 KB
#include "gondola.h"

#include<bits/stdc++.h>
using namespace std;

int valid(int n, int inputSeq[])
{
    int ind[n+1];
    for(int i=0;i<=n;i++)ind[i]=-1;
    unordered_set<int>seen;
    for(int i=0;i<n;i++){
        if(seen.count(inputSeq[i]))return 0;
        seen.insert(inputSeq[i]);
        if(inputSeq[i]<=n){
            ind[inputSeq[i]]=i;
        }
    }
    int val=-1,beg;
    for(int i=1;i<=n;i++){
        if(ind[i]!=-1){
            val=i;
            beg=ind[i];
            break;
        }
    }
    if(val==-1)return 1;
    for(int j=(beg+1)%n;j!=beg;j=(j+1)%n){
        val++;
        if(inputSeq[j]==val)continue;
        if(inputSeq[j]<=n)return 0;
    }
    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    #define a gondolaSeq 
    #define b replacementSeq 
    int ind[n+1];
    for(int i=0;i<=n;i++)ind[i]=-1;
    for(int i=0;i<n;i++){
        if(a[i]<=n){
            ind[a[i]]=i;
        }
    }
    int val=1,beg=0;
    for(int i=1;i<=n;i++){
        if(ind[i]!=-1){
            val=i;
            beg=ind[i];
            break;
        }
    }
    int begval[n];
    begval[beg]=val;
    for(int j=(beg+1)%n;j!=beg;j=(j+1)%n){
        val++;
        if(n<val)val-=n;
        begval[j]=val;
    }
    int place=0;
    int cur=n+1;
    int p[n];
    for(int i=0;i<n;i++){
        p[i]=i;
    }
    sort(p,p+n,[&](int i,int j)->bool {
        return a[i]<a[j];
    });
    for(int i=0;i<n;i++){
        int pp=p[i];
        while(begval[pp]<a[pp]){
            b[place++]=begval[pp];
            begval[pp]=cur++;
        }
    }
    return place;
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 356 KB Output is correct
5 Correct 1 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 352 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 352 KB Output is correct
6 Correct 5 ms 2408 KB Output is correct
7 Correct 6 ms 1632 KB Output is correct
8 Correct 9 ms 4212 KB Output is correct
9 Correct 3 ms 1888 KB Output is correct
10 Correct 15 ms 4752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 356 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 352 KB Output is correct
6 Correct 5 ms 2236 KB Output is correct
7 Correct 6 ms 1628 KB Output is correct
8 Correct 10 ms 4208 KB Output is correct
9 Correct 3 ms 1884 KB Output is correct
10 Correct 11 ms 4716 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 6 ms 2240 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 15 ms 6256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 356 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 400 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 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 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 1880 KB Output is correct
12 Correct 13 ms 2168 KB Output is correct
13 Correct 15 ms 1796 KB Output is correct
14 Correct 7 ms 1884 KB Output is correct
15 Correct 12 ms 2500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -