Submission #1250819

#TimeUsernameProblemLanguageResultExecution timeMemory
1250819hmms127Gondola (IOI14_gondola)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "gondola.h"
#define pb push_back
using namespace std;

int valid(int n, int a[])
{
    int idx;
    for(int i=0;i<n;i++){
        if(a[i]==1){idx=i;break;}
    }
    int sm=0;
    for(int i=idx;i<n;i++)sm+=a[i];
    int sz=n-idx;
    return (sm==sz*(sz+1)/2);
    
}
//----------------------

int replacement(int n, int a[], int replacementSeq[])
{
  vector<array<int,2>>v;
  int f=0;
  for(int i=0;i<n;i++){
      if(a[i]<=n){
          f=i-(a[i]-1);
          f+=(p<0 ? n:0);
      }
  }
  for(int i=0;i<n;i++){
      if(a[i]>n)v.pb({a[i],i});
  }
  sort(v.begin(),v.end());
  int cnt=0,idx=0,cur_val=n;
  for(auto it:v){
      int x=it.second-f+1;
      x+=(x<0 ? n:0);
      replacementSeq[idx++]=x;
      cur_val++;
      while(cur_val<it.first){
          replacementSeq[idx++]=cur_val++;
          cnt++;
      }
  }
  return cnt;
}

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

int countReplacement(int n, int a[])
{
  int cnt=0,mx=0;
  for(int i=0;i<n;i++){
     cnt+=(a[i]>n);
     mx=max(mx,a[i]);
  }
  return (cnt==3 ? 1:(cnt==2&&mx==n+3 ? 2:1));
}

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:27:15: error: 'p' was not declared in this scope
   27 |           f+=(p<0 ? n:0);
      |               ^
gondola.cpp:36:16: error: 'struct std::array<int, 2>' has no member named 'second'
   36 |       int x=it.second-f+1;
      |                ^~~~~~
gondola.cpp:40:24: error: 'struct std::array<int, 2>' has no member named 'first'
   40 |       while(cur_val<it.first){
      |                        ^~~~~