Submission #1360678

#TimeUsernameProblemLanguageResultExecution timeMemory
1360678nini_gvenetadzeGondola (IOI14_gondola)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#include "gondola.h"
int valid(int n, int inputseq[])
{
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            if(inputseq[i]==inputseq[j])
            {
                return 0;
            }
        }
    }

    int k=-1; 
    int c=-1; 
    for(int i=0; i<n; i++)
    {
        if(inputseq[i]<=n)
        {
            if(c==-1)
            {
                c=inputseq[i];
                k=i;
                continue;
            }

            if(inputseq[i]==1)
            {
                c=inputseq[i];
                k=i;
                continue;
            }

            if(inputseq[i]-c!=i-k)
            {
                return 0;
            }

            c=inputseq[i];
            k=i;
        }
    }

    return 1;
}

int replacement(int n, int gondolaseq[],  int replacementseq[])
{
    int a[2*n];
    int ans=0;
    for(int i=0; i<n; i++)
    {
        a[i]=gondolaseq[i];
        a[i+n]=gondolaseq[i];
    }
    vector<pair<int, int>> v;

    itn ind=-1;

    for(int i=0; i<n; i++)
    {
        if(a[i]<=n)
        {
            ind=i;
            int x=a[i];
            for(int j=i; j<i+n; j++)
            {
                if(a[j]!=x)
                {
                    v.push_back({a[j], x});
                }
                x++;
                if(x>n) x=1;
            }
            break;
        }
    }
    if(ind==-1)
    {
        for(int i=0; i<n; i++)
        {
            replacementseq[i]=i+1;
        }
        return n;
    }
    sort(v.begin(), v.end());

    int k=n+1;
    for(int i=0; i<(int)v.size(); i++)
    {
        replacementseq[ans++]=v[i].second;
        while(k<v[i].first)
        {
        replacementseq[ans++]=k;
        k++;
        }
        if(k==v[i].first) k++;
    }
    return ans;
}







int countReplacement(int n, int inputSeq[]){
    return 0;
}

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:61:5: error: 'itn' was not declared in this scope; did you mean 'int'?
   61 |     itn ind=-1;
      |     ^~~
      |     int
gondola.cpp:67:13: error: 'ind' was not declared in this scope; did you mean 'int'?
   67 |             ind=i;
      |             ^~~
      |             int
gondola.cpp:81:8: error: 'ind' was not declared in this scope; did you mean 'int'?
   81 |     if(ind==-1)
      |        ^~~
      |        int