제출 #1006596

#제출 시각아이디문제언어결과실행 시간메모리
1006596Mardonbekhazratov게임 (IOI14_game)C++17
컴파일 에러
0 ms0 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int n; vector<int>p,c; vector<bool>vis; int find(int x){ if(x==p[x]) return x; return p[x]=find(p[x]); } bool unite(int x,int y){ x=find(x); y=find(y); if(x==y) return 1; } void initialize(int N) { n=N; p.resize(n); iota(p.begin(),p.end(),0); c.assign(n,0); vis.assign(n,0); } int hasEdge(int u, int v) { c[u]++; c[v]++; if((c[u]==n-1&&!vis[u]) || (c[v]==n-1 && !vis[v])){ vis[u]=true; vis[v]=true; return 1; } return 0; } int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } int main() { int n, u, v; n = read_int(); initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { u = read_int(); v = read_int(); printf("%d\n", hasEdge(u, v)); } return 0; }

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

game.cpp: In function 'bool unite(int, int)':
game.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
/usr/bin/ld: /tmp/ccZcpGfJ.o: in function `read_int()':
grader.cpp:(.text+0x0): multiple definition of `read_int()'; /tmp/cccPbXxJ.o:game.cpp:(.text+0x2e0): first defined here
/usr/bin/ld: /tmp/ccZcpGfJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cccPbXxJ.o:game.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status