제출 #572708

#제출 시각아이디문제언어결과실행 시간메모리
572708kartel슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "grader.cpp" //#include "supertrees.h" #define sz(x) (int)x.size() #define pb push_back using namespace std; const int N = 1e3 + 500; int pr[N]; int prl[N]; int f(int v) {return (pr[v] == v ? v : pr[v] = f(pr[v]));} void link(int a, int b) { a = f(a); b = f(b); pr[a] = b; } int fl(int v) {return (prl[v] == v ? v : prl[v] = f(prl[v]));} void linkl(int a, int b) { a = fl(a); b = fl(b); prl[a] = b; } int construct(vector <vector <int> > p) { int n = sz(p); for (int i = 0; i < n; i++) { pr[i] = i; prl[i] = i; } vector <int> cnt(4, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] == 1 && i != j) { link(i, j); } cnt[p[i][j]]++; if (p[i][j]) { linkl(i, j); } } } if (cnt[2] && cnt[3]) { return 0; } vector <vector <int> > b(n, vector <int> (n, 0)); vector <set<int> > cp(n); for (int i = 0; i < n; i++) { cp[fl(i)].insert(i); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (f(i) == f(j) && !p[i][j]) { return 0; } if (fl(i) == fl(j) && !p[i][j]) { return 0; } } } vector <int> used(n, 0); for (int it1 = 0; it1 < n; it1++) { if (used[fl(it1)]) { continue; } set <int> cyc; vector <int> c; for (auto i : cp[fl(it1)]) { if (cyc.count(f(i))) { continue; } cyc.insert(f(i)); c.pb(i); } if (cnt[3] && sz(cyc) < 4) { return 0; } if (cnt[2] && sz(cyc) < 3) { return 0; } for (int i = 0; i < sz(c); i++) { b[c[i]][c[(i + 1) % sz(c)]] = 1; b[c[(i + 1) % sz(c)]][c[i]] = 1; } if (cnt[3]) { b[c[1]][c[2]] = 1; b[c[2]][c[1]] = 1; } vector <vector <int> > cmp(n); set <int> cmps; for (auto i : cp[fl(it1)]) { cmp[f(i)].pb(i); cmps.insert(f(i)); } if (sz(cmps) > sz(c)) { return 0; } int it = 0; for (auto i : cp[fl(it1)]) { if (sz(cmp[i])) { int last = cmp[i][0]; for (auto x : cmp[i]) { if (x == last) { continue; } b[last][x] = 1; b[x][last] = 1; last = x; } } } } for (int i = 0; i < n; i++) { b[i][i] = 0; } build(b); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:108:13: warning: unused variable 'it' [-Wunused-variable]
  108 |         int it = 0;
      |             ^~
/usr/bin/ld: /tmp/ccvwaf6C.o: in function `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x320): multiple definition of `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'; /tmp/cc4mMqJB.o:supertrees.cpp:(.text+0x7c0): first defined here
/usr/bin/ld: /tmp/ccvwaf6C.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4mMqJB.o:supertrees.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status