# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
902973 | 2024-01-11T05:00:52 Z | Muhammad_Aneeq | Friend (IOI14_friend) | C++17 | 1000 ms | 34484 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; } for (int i=0;i<n;i++) 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 | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 0 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 | Correct | 1 ms | 2404 KB | Output is correct |
13 | Correct | 1 ms | 2400 KB | Output is correct |
14 | Correct | 1 ms | 2408 KB | Output is correct |
15 | Correct | 0 ms | 2408 KB | Output is correct |
16 | Correct | 1 ms | 2408 KB | Output is correct |
17 | Correct | 3 ms | 2408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4456 KB | Output is correct |
2 | Correct | 1 ms | 6644 KB | Output is correct |
3 | Correct | 1 ms | 6504 KB | Output is correct |
4 | Correct | 3 ms | 8808 KB | Output is correct |
5 | Correct | 4 ms | 10856 KB | Output is correct |
6 | Correct | 2 ms | 6504 KB | Output is correct |
7 | Correct | 2 ms | 6744 KB | Output is correct |
8 | Correct | 2 ms | 10856 KB | Output is correct |
9 | Correct | 2 ms | 8808 KB | Output is correct |
10 | Correct | 4 ms | 10856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6492 KB | Output is correct |
2 | Correct | 5 ms | 10840 KB | Output is correct |
3 | Correct | 1 ms | 4696 KB | Output is correct |
4 | Correct | 3 ms | 8796 KB | Output is correct |
5 | Correct | 5 ms | 10844 KB | Output is correct |
6 | Correct | 1 ms | 2396 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 | 5 ms | 10844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 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 | 2392 KB | Output is correct |
5 | Execution timed out | 1045 ms | 10844 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 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 | 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 | 2392 KB | Output is correct |
9 | Execution timed out | 1071 ms | 10840 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 | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 0 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 | 2392 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Runtime error | 102 ms | 34484 KB | Execution killed with signal 11 |
13 | Halted | 0 ms | 0 KB | - |