답안 #126777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126777 2019-07-08T11:51:50 Z ekrem 곤돌라 (IOI14_gondola) C++
컴파일 오류
0 ms 0 KB
// #include "gondola.h"
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, a[N], u[N];


int valid(int n, int a[]){
	int x = inf;
	for(int i = 0; i < n; i++){
		a[i]--;
		if(u[a[i]])return 0;
		u[a[i]] = 1;
		if(a[i] < n and a[i] >= 0){
			if(x != inf and x != (a[i] - i + n)%n )
				return 0;
			x = (a[i] - i + n)%n;
		}
	}
	return 1;
}

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

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()
{
	freopen("in.txt", "r", stdin);
	freopen("outt.txt", "w", stdout);
  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

gondola.cpp: In function 'int main()':
gondola.cpp:59:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("in.txt", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
gondola.cpp:60:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("outt.txt", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccU1Fx44.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccqM32lr.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccU1Fx44.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/ccqM32lr.o:(.bss+0xf4260): first defined here
/tmp/ccU1Fx44.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/ccqM32lr.o:(.bss+0x0): first defined here
/tmp/ccU1Fx44.o: In function `main':
grader.cpp:(.text.startup+0xc3): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0xe2): undefined reference to `valid'
grader.cpp:(.text.startup+0x106): undefined reference to `replacement'
collect2: error: ld returned 1 exit status