Submission #932747

# Submission time Handle Problem Language Result Execution time Memory
932747 2024-02-24T06:13:28 Z vjudge1 Gondola (IOI14_gondola) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
 
using namespace std;
 
#define F first
#define S second
#define ll long long
// #define int ll
#define pb push_back
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,i) memset(a,i,sizeof(a))
#define in insert
#define lb lower_bound
#define ub upper_bound
#define y1 yy
#define ppb pop_back
#define ull unsigned ll
 
const int MAX=3e6+55;
const int inf=1e9;
const int N=2e5;
const int C=331;
const int C1=431;
const int mod=1e9+9;
const int mod1=1e9+9;
// #include "gondola.h"

int pos[MAX];

int valid(int n, int a[])
{
  int mn=0;
  for(int i=0;i<n;i++){
    if(a[i]<a[mn])mn=i;
    // pos[a[i]]=i;
  }
  vector<int> v;
  for(int i=mn;i<n;i++){
    if(a[i]<=n){
      v.pb(a[i]);
      pos[a[i]]=i-mn;
    }
  }
  for(int i=0;i<mn;i++){
    if(a[i]<=n){
      v.pb(a[i]);
      pos[a[i]]=n-mn+i;
    }
  }
  for(int i=1;i<sz(v);i++){
    if(v[i]<=v[i-1]||v[i]-v[i-1]!=pos[v[i]]-pos[v[i-1]])return 0;
  }
  sort(a,a+n);
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1])return 0;
  }
  return 1;
}


int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

//----------------------
int countReplacement(int n, int a[])
{
  ll ans=1;
  if(!valid(n,a))return 0;
  vector<int> v;
  for(int i=0;i<n;i++){
    if(a[i]>n){
      v.pb(a[i]);
    }
  }
  sort(all(v));
  int r=n+1;
  for(int i=0;i<sz(v);i++){
    while(r<v[i]){
      ans=ans*1ll*(sz(v)-i)%mod;
      r++;
    }
    r++;
  }
  if(sz(v)==n)ans=ans*1ll*n%mod;
  return ans;
}

Compilation message

/usr/bin/ld: /tmp/ccBTXOX6.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status