제출 #422178

#제출 시각아이디문제언어결과실행 시간메모리
422178dreezy곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

/**********************/


int valid(int n, int inputSeq[])
{
	
	int preval = -1;
	for(int i =0; i<n; i++){
		//cout << preval<<endl;
		if(preval == -1){
			if(inputSeq[i] <= n)
				preval = inputSeq[i];
			continue;
		}
		
		if(inputSeq[i] <=n){
			if(preval == n){
				if(inputSeq[i] != 1) return false;
			}
			else
				if(inputSeq[i]!= preval+1) return false;
			preval = inputSeq[i];
		}
		else{
			//replacement, num can be anything
			
			if(preval == n)
				preval = 1;
			else preval++;
		}
	}
	
	if(inputSeq[n-1] == n)
		return inputSeq[0] == 1;
	else return inputSeq[n-1] +1 == inputSeq[0];
	
}

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

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

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

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


/******************************/

int gondolaSequence[100001];
int replacementSequence[250001];

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;
}

컴파일 시 표준 에러 (stderr) 메시지

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