Submission #492943

# Submission time Handle Problem Language Result Execution time Memory
492943 2021-12-09T20:13:42 Z ivan_tudor Cats or Dogs (JOI18_catdog) C++14
Compilation error
0 ms 0 KB
#include "catdog.h"
#include <cstdio>
#include <cassert>
#include <vector>
#include <stdlib.h>

int readInt(){
	int i;
	if(scanf("%d",&i)!=1){
		fprintf(stderr,"Error while reading input\n");
		exit(1);
	}
	return i;
}

int main(){
	freopen(".in", "r", stdin);
	int N=readInt();

	std::vector<int> A(N-1),B(N-1);
	for(int i=0;i<N-1;i++)
	{
		A[i]=readInt();
		B[i]=readInt();
	}
	int Q;
	assert(scanf("%d",&Q)==1);
	std::vector <int> T(Q),V(Q);
	for(int i=0;i<Q;i++)
	{
		T[i]=readInt();
		V[i]=readInt();
	}

	initialize(N,A,B);

	std::vector<int> res(Q);
	for(int j=0;j<Q;j++)
	{
		if(T[j]==1) res[j]=cat(V[j]);
		else if(T[j]==2) res[j]=dog(V[j]);
		else res[j]=neighbor(V[j]);
	}
	for(int j=0;j<Q;j++)
		printf("%d\n",res[j]);
	return 0;
}

Compilation message

catdog.cpp: In function 'int main()':
catdog.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  freopen(".in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccTf6zuO.o: in function `readInt()':
grader.cpp:(.text+0x0): multiple definition of `readInt()'; /tmp/ccQMk5VJ.o:catdog.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccTf6zuO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQMk5VJ.o:catdog.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccQMk5VJ.o: in function `main':
catdog.cpp:(.text.startup+0x211): undefined reference to `initialize(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: catdog.cpp:(.text.startup+0x249): undefined reference to `neighbor(int)'
/usr/bin/ld: catdog.cpp:(.text.startup+0x28d): undefined reference to `dog(int)'
/usr/bin/ld: catdog.cpp:(.text.startup+0x331): undefined reference to `cat(int)'
/usr/bin/ld: /tmp/ccTf6zuO.o: in function `main':
grader.cpp:(.text.startup+0x1f1): undefined reference to `initialize(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x229): undefined reference to `neighbor(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x26d): undefined reference to `dog(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x311): undefined reference to `cat(int)'
collect2: error: ld returned 1 exit status