제출 #113962

#제출 시각아이디문제언어결과실행 시간메모리
113962baqargam게임 (IOI14_game)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio> #include <cassert> #include "game.h" using namespace std; int n,m,k,l,i,j,a,b,col[1505],sz[1505],d[1505][1505]; int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } void unite(int a,int b){ sz[a]+=sz[b]; for(int i=0;i<n;i++){ if(col[i]==b) col[i]=a; d[a][i]+=d[b][i]; } } int hasEdge(int a,int b){ if(d[col[a]][col[b]]+1==sz[a]*sz[b]) { unite(col[a],col[b]); return 1; } else return 0; } int main() { int u, v; n = read_int(); initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { a = read_int(); b = read_int(); printf("%d\n", hasEdge(u, v)); } return 0; }

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

game.cpp: In function 'int main()':
game.cpp:40:15: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
         printf("%d\n", hasEdge(u, v));
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
game.cpp:40:15: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
/tmp/ccKzTLyT.o: In function `read_int()':
grader.cpp:(.text+0x0): multiple definition of `read_int()'
/tmp/ccAKjXz0.o:game.cpp:(.text+0x0): first defined here
/tmp/ccKzTLyT.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccAKjXz0.o:game.cpp:(.text.startup+0x0): first defined here
/tmp/ccAKjXz0.o: In function `main':
game.cpp:(.text.startup+0xf): undefined reference to `initialize(int)'
/tmp/ccKzTLyT.o: In function `main':
grader.cpp:(.text.startup+0x14): undefined reference to `initialize(int)'
collect2: error: ld returned 1 exit status