# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902981 | 2024-01-11T05:04:36 Z | Muhammad_Aneeq | Friend (IOI14_friend) | C++17 | 1000 ms | 34640 KB |
#include <vector> #include <iostream> #include <set> #include "friend.h" using namespace std; int const N=2000; int ed[N][N]={}; int vis[N]={}; int ans=0; int nn; int val[N]={}; int cur[N]={}; void dfs(int i,int val1) { vis[i]=1; for (int j=0;j<nn;j++) cur[j]=cur[j]+(ed[i][j]==0); for (int j=0;j<nn;j++) { if (ed[i][j]&&!vis[j]&&cur[j]==0) dfs(j,val1+val[j]); } vis[i]=0; for (int j=0;j<nn;j++) cur[j]=cur[j]-(ed[i][j]==0); ans=max(ans,val1); } int findSample(int n,int confidence[],int host[],int protocol[]) { nn=n; for (int i=0;i<n;i++) val[i]=confidence[i]; for (int i=0;i<n;i++) for (int j=0;j<n;j++) ed[i][j]=1; set<int>s; for (int i=1;i<n;i++) { s.insert(protocol[i]); if (protocol[i]==0) ed[i][host[i]]=ed[host[i]][i]=0; else if (protocol[i]==1) { for (int j=0;j<n;j++) { if (ed[host[i]][j]==0) ed[i][j]=ed[j][i]=0; } } else { ed[i][host[i]]=ed[host[i]][i]=0; for (int j=0;j<n;j++) { if (ed[host[i]][j]==0) ed[i][j]=ed[j][i]=0; } } } if (s.size()==1&&*begin(s)==1) { int ans=0; for (int i=0;i<n;i++) ans+=val[i]; return ans; } dfs(0,val[0]); for (int i=0;i<n;i++) { if (ed[0][i]==0) dfs(i,val[i]); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2392 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2468 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4456 KB | Output is correct |
2 | Correct | 1 ms | 6504 KB | Output is correct |
3 | Correct | 1 ms | 6504 KB | Output is correct |
4 | Correct | 2 ms | 8808 KB | Output is correct |
5 | Correct | 3 ms | 10856 KB | Output is correct |
6 | Correct | 1 ms | 6504 KB | Output is correct |
7 | Correct | 1 ms | 6504 KB | Output is correct |
8 | Correct | 3 ms | 11112 KB | Output is correct |
9 | Correct | 2 ms | 8808 KB | Output is correct |
10 | Correct | 3 ms | 10852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6504 KB | Output is correct |
2 | Correct | 5 ms | 10844 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 4 ms | 10844 KB | Output is correct |
6 | Correct | 1 ms | 2392 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 2 ms | 6492 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 8 ms | 10844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2392 KB | Output is correct |
5 | Execution timed out | 1070 ms | 10844 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 0 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2392 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 0 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Execution timed out | 1071 ms | 10844 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2392 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Runtime error | 101 ms | 34640 KB | Execution killed with signal 11 |
13 | Halted | 0 ms | 0 KB | - |