# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775336 | 2023-07-06T09:48:29 Z | danikoynov | Friend (IOI14_friend) | C++14 | 1 ms | 468 KB |
#include "friend.h" #include<bits/stdc++.h> using namespace std; // Find out best sample const int maxn = 1010; typedef long long ll; vector < int > adj[maxn]; void add_edge(int v, int u) { adj[v].push_back(u); adj[u].push_back(v); } vector < int > ord; int used[maxn]; void bfs(int v) { queue < int > q; used[v] = 1; q.push(v); while(!q.empty()) { int cur = q.front(); q.pop(); ord.push_back(cur); for (int u : adj[cur]) { if (used[u] == 0) { if (used[cur] == 1) used[u] = 2; else used[u] = 1; q.push(u); } } } } int findSample(int n,int confidence[],int host[],int protocol[]) { bool only_my = true, only_we = true; for (int i = 1; i < n; i ++) { if (protocol[i] != 1) only_my = false; if (protocol[i] != 2) only_we = false; } /**if (only_my) { int ans = 0; for (int i = 0; i < n; i ++) ans += confidence[i]; return ans; } else if (only_we) { int ans = 0; for (int i = 0; i < n; i ++) ans = max(ans, confidence[i]); return ans; } else*/ { for (int i = 1; i < n; i ++) { if (protocol[i] == 0) { add_edge(i, host[i]); } else { assert(0); } /**if (protocol[i] == 2) { for (int u : adj[host[i]]) add_edge(u, i); }*/ } ll ans = 0; for (int i = 0; i < n; i ++) { if (!used[i]) { ord.clear(); bfs(i); int s1 = 0, s2 = 0; for (int v : ord) { if (used[v] == 1) s1 += confidence[v]; else s2 += confidence[v]; } ans = ans + max(s1, s2); } } return ans; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 340 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |