# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
780254 |
2023-07-12T07:42:53 Z |
Sohsoh84 |
Friend (IOI14_friend) |
C++17 |
|
1 ms |
852 KB |
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << x << endl;
const int MAXN = 1e4 + 10;
int dp[MAXN], C[MAXN], col[MAXN], ans[2], n;
vector<int> adj[MAXN];
inline void add(int u, int v) {
adj[u].push_back(v);
adj[v].push_back(u);
}
void dfs(int v) {
ans[col[v] - 1] += C[v];
for (int u : adj[v]) {
if (!col[u]) {
col[u] = 3 - col[u];
dfs(u);
}
}
}
int findSample(int n, int C_[], int host[], int protocol[]){
for (int i = 0; i < n; i++)
C[i] = C_[i];
for (int i = 1; i < n; i++) {
if (protocol[i] % 2 == 0) add(host[i], i);
if (protocol[i] > 0) {
for (int u : adj[host[i]])
add(i, u);
}
}
int fans = 0;
for (int i = 0; i < n; i++) {
if (!col[i]) {
ans[0] = ans[1] = 0;
col[i] = 1;
dfs(i);
fans += max(ans[0], ans[1]);
}
}
return fans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |