제출 #1074028

#제출 시각아이디문제언어결과실행 시간메모리
1074028deera친구 (IOI14_friend)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+5; set<int> adj[MAXN]; vector<int> CONF; int dfs(int u, int p = -1, bool count = true) { int ans = 0; if (count) ans = CONF[u]; for (auto v: adj[u]) { if (v == p) continue; ans += dfs(v, u, !count); } return ans; } // Find out best sample int findSample(int n, int confidence[], int host[], int protocol[]){ CONF.clear(); for (int i = 0; i < n; i++) CONF.push_back(confidence[i]); for (int i = 0; i < n; i++) { if (i == 0) continue; int h = host[i]; switch (protocol[i]) { case 0: // I am your friend adj[h].insert(i); adj[i].insert(h); break; case 1: // my friends are your friends for (int f: adj[h]) { if (h == f) continue; adj[i].insert(f); adj[f].insert(i); } break; case 2: // we are your friends adj[h].insert(i); adj[i].insert(h); for (int f: adj[h]) { if (h == f) continue; adj[i].insert(f); adj[f].insert(i); } break; } } // a friend can't be a friend of themselves for (int i = 0; i < n; i++) adj[i].erase(i); // for (int i = 0; i < n; i++) { // cerr << i << ": "; // for (auto x: adj[i]) cerr << x << " "; // cerr << endl; // } if (n <= 10) { int max_ans = 0; int ans = 0; for (int i = 0; i < (1 << n); i++) { set<int> s; for (int j = 0; j < n; j++) if (i & (1 << j)) s.insert(j); bool ok = true; for (auto x: s) for (auto f: adj[x]) if (s.count(f)) { ok = false; break; } if (!ok) continue; for (auto x: s) ans += confidence[x]; max_ans = max(max_ans, ans); ans = 0; } return max_ans; } int hist[3] = {0, 0, 0}; int sum = 0; int maxi = 0; for (int i = 0; i < n; i++) { if (i == 0) continue; hist[protocol[i]]++; sum += confidence[i]; maxi = max(maxi, confidence[i]); } // if (hist[0] == n) { // int ans = dfs(0); // return max(ans, abs(sum - ans)); // } if (hist[0] == 0 && hist[2] == 0) { return sum; } // if (hist[0] == 0 && hist[1] == 0) { // return maxi; // } return 0; } signed main() { int n = 6; int confidence[] = {13, 3, 6, 20, 10, 15}; int host[] = {0, 0, 0, 1, 2, 0}; int protocol[] = {0, 0, 1, 2, 1, 0}; cout << findSample(n, confidence, host, protocol) << endl; }

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

/usr/bin/ld: /tmp/ccqHFcxb.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWTBqQ8.o:friend.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status