Submission #775423

# Submission time Handle Problem Language Result Execution time Memory
775423 2023-07-06T11:32:21 Z alvingogo Gondola (IOI14_gondola) C++14
Compilation error
0 ms 0 KB
#include "gondola.h"
#include <bits/stdc++.h>
#define fs fireplacementSeqt
#define sc second
using namespace std;

int valid(int n, int inputSeq[])
{
    int x=-1;
    for(int i=0;i<n;i++){
        if(inputSeq[i]<=n){
            x=i;
        }  
    }
    if(x==-1){
        return 1;
    }
    for(int i=x,cnt=0;cnt<n;i=(i+1)%n,cnt++){
        if((inputSeq[i]-inputSeq[x]+n)%n!=(i-x+n)%n){
            return 0;
        }
    }
    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int x=-1;
    for(int i=0;i<n;i++){
        if(gondolaSeq[i]<=n){
            x=i;
        }  
    }
    if(x==-1){
        x=0;
    }
    vector<pair<int,int> > g;
    for(int i=x,cnt=0,z=gondolaSeq[x];cnt<n;i=(i+1)%n,cnt++,z=(z+1)%n+(n*(z==n-1))){
        if(gondolaSeq[i]>n){
            g.push_back({gondolaSeq[i],z});
        }
    }
    sort(g.begin(),g.end());
    int nw=n+1,f=0;
    for(auto y:g){
        replacementSeq[f]=y.sc;
        f++;
        nw++;
        for(;nw<=y.fs;f++,nw++){
            replacementSeq[f]=nw-1;
        }
    }
    return f;
}#include "gondola.h"
#include <bits/stdc++.h>
#define fs fireplacementSeqt
#define sc second
using namespace std;

int valid(int n, int inputSeq[])
{
    int x=-1;
    for(int i=0;i<n;i++){
        if(inputSeq[i]<=n){
            x=i;
        }  
    }
    if(x==-1){
        return 1;
    }
    for(int i=x,cnt=0;cnt<n;i=(i+1)%n,cnt++){
        if((inputSeq[i]-inputSeq[x]+n)%n!=(i-x+n)%n){
            return 0;
        }
    }
    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int x=-1;
    for(int i=0;i<n;i++){
        if(gondolaSeq[i]<=n){
            x=i;
        }  
    }
    if(x==-1){
        x=0;
    }
    vector<pair<int,int> > g;
    for(int i=x,cnt=0,z=gondolaSeq[x];cnt<n;i=(i+1)%n,cnt++,z=(z+1)%n+(n*(z==n-1))){
        if(gondolaSeq[i]>n){
            g.push_back({gondolaSeq[i],z});
        }
    }
    sort(g.begin(),g.end());
    int nw=n+1,f=0;
    for(auto y:g){
        replacementSeq[f]=y.sc;
        f++;
        nw++;
        for(;nw<=y.fs;f++,nw++){
            replacementSeq[f]=nw-1;
        }
    }
    return f;
}

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

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


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

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

Compilation message

gondola.cpp:56:2: error: stray '#' in program
   56 | }#include "gondola.h"
      |  ^
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:3:12: error: 'struct std::pair<int, int>' has no member named 'fireplacementSeqt'
    3 | #define fs fireplacementSeqt
      |            ^~~~~~~~~~~~~~~~~
gondola.cpp:51:20: note: in expansion of macro 'fs'
   51 |         for(;nw<=y.fs;f++,nw++){
      |                    ^~
gondola.cpp: At global scope:
gondola.cpp:56:3: error: 'include' does not name a type
   56 | }#include "gondola.h"
      |   ^~~~~~~
gondola.cpp:62:5: error: redefinition of 'int valid(int, int*)'
   62 | int valid(int n, int inputSeq[])
      |     ^~~~~
gondola.cpp:7:5: note: 'int valid(int, int*)' previously defined here
    7 | int valid(int n, int inputSeq[])
      |     ^~~~~
gondola.cpp:83:5: error: redefinition of 'int replacement(int, int*, int*)'
   83 | int replacement(int n, int gondolaSeq[], int replacementSeq[])
      |     ^~~~~~~~~~~
gondola.cpp:28:5: note: 'int replacement(int, int*, int*)' previously defined here
   28 | int replacement(int n, int gondolaSeq[], int replacementSeq[])
      |     ^~~~~~~~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:58:12: error: 'struct std::pair<int, int>' has no member named 'fireplacementSeqt'
   58 | #define fs fireplacementSeqt
      |            ^~~~~~~~~~~~~~~~~
gondola.cpp:106:20: note: in expansion of macro 'fs'
  106 |         for(;nw<=y.fs;f++,nw++){
      |                    ^~
gondola.cpp: At global scope:
gondola.cpp:123:5: error: redefinition of 'int countReplacement(int, int*)'
  123 | int countReplacement(int n, int inputSeq[])
      |     ^~~~~~~~~~~~~~~~
gondola.cpp:115:5: note: 'int countReplacement(int, int*)' previously defined here
  115 | int countReplacement(int n, int inputSeq[])
      |     ^~~~~~~~~~~~~~~~