Submission #953605

# Submission time Handle Problem Language Result Execution time Memory
953605 2024-03-26T10:13:19 Z emad234 Gondola (IOI14_gondola) C++17
Compilation error
0 ms 0 KB
#include "gondola.h"
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<ll, ll>
const ll mod = 1e9 + 9;
const ll mxN = 1e6 + 5;
using namespace std;
int gondolaSequence[100001];
int replacementSequence[250001];
int valid(int n, int inputSeq[])
{
  vector<bool> vis(250000 + 3);
  int st = 0;
  int val = 1;
  for (int i = 0; i < n; i++)
  {
    if (vis[inputSeq[i]])
      return 0;
    vis[inputSeq[i]] = 1;
    if (inputSeq[i] <= n)
    {
      st = i;
      val = inputSeq[i];
    }
  }
  int og = st;
  while (1)
  {
    st++;
    val++;
    if (st >= n)
      st = 0;
    if (val > n)
      val = 1;
    if (st == og)
      break;
    if (inputSeq[st] != val && inputSeq[st] <= n)
      return 0;
  }
  return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  set<int> s;
  int mx = 0;
  for (int i = 0; i < n; i++)
    mx = max(mx, gondolaSeq[i]);
  for (int i = 1; i <= mx; i++)
    s.insert(i);
  for (int i = 0; i < n; i++)
    s.erase(gondolaSeq[i]);
  int id = 0;
  while(s.size()){
    replacementSeq[id] = *s.begin();
    s.erase(s.begin());
    id++;
  }
  return id + 1;
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
int main()
{
  int i, n, tag;
  int nr; 
  assert(scanf("%d", &tag)==1);
  assert(scanf("%d", &n)==1);
  for(i=0;i< n;i++)
    assert( scanf("%d", &gondolaSequence[i]) ==1);
  
  switch (tag){
  case 1: case 2: case 3:
    printf("%d\n", valid(n, gondolaSequence));
    break;

  case 4: case 5: case 6:
    nr = replacement(n, gondolaSequence, replacementSequence);
    printf("%d ", nr);
    if (nr > 0)
      {
	for (i=0; i<nr-1; i++)
	  printf("%d ", replacementSequence[i]);
	printf("%d\n", replacementSequence[nr-1]);
      }  
    else printf("\n");
    break;

  case 7: case 8: case 9: case 10:
    printf("%d\n",  countReplacement(n, gondolaSequence));  
    break;
  }

  return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccOOvCZf.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cciZR1Oe.o:gondola.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOOvCZf.o:(.bss+0xf4260): multiple definition of `gondolaSequence'; /tmp/cciZR1Oe.o:(.bss+0xf4260): first defined here
/usr/bin/ld: /tmp/ccOOvCZf.o:(.bss+0x0): multiple definition of `replacementSequence'; /tmp/cciZR1Oe.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status