Submission #404181

#TimeUsernameProblemLanguageResultExecution timeMemory
404181wmrmrFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; bool adj[10][10]; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ int ans = 0; bool pt2 = 1, pt3 = 1, pt4 = 1; for(int i=1;i<n;i++) { if(protocol[i] != 0) pt4 = 0; if(protocol[i] != 1) pt2 = 0; if(protocol[i] != 2) pt3 = 0; } if(n <= 10) { ans = 0; for(int i=1;i<n;i++) { int p = host[i]; if(protocol[i] != 1) adj[i][p] = adj[p][i] = 1; if(protocol[i] != 0) for(int j=0;j<i;j++) adj[i][j] = adj[j][i] = adj[j][i] || adj[p][j]; } int dbg = 0; for(int cur = 0 ; cur < (1<<n) ; cur++) { bool valid = 1; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { if( (cur&(1<<i)) && (cur&(1<<j)) ) if(adj[i][j]) valid = 0; #include "friend.h" #include <bits/stdc++.h> using namespace std; bool adj[10][10]; // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ int ans = 0; bool pt2 = 1, pt3 = 1, pt4 = 1; for(int i=1;i<n;i++) { if(protocol[i] != 0) pt4 = 0; if(protocol[i] != 1) pt2 = 0; if(protocol[i] != 2) pt3 = 0; } if(n <= 10) { ans = 0; for(int i=1;i<n;i++) { int p = host[i]; if(protocol[i] != 1) adj[i][p] = adj[p][i] = 1; if(protocol[i] != 0) for(int j=0;j<i;j++) adj[i][j] = adj[j][i] = adj[j][i] || adj[p][j]; } int dbg = 0; for(int cur = 0 ; cur < (1<<n) ; cur++) { bool valid = 1; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { if( (cur&(1<<i)) && (cur&(1<<j)) ) if(adj[i][j]) valid = 0; } int temp = 0; for(int i=0;i<n;i++) if(cur&(1<<i)) temp += confidence[i]; if(valid) ans = max(ans,temp), dbg = cur; } return ans; } if(pt2) { for(int i=0;i<n;i++) ans += confidence[i]; return ans; } if(pt3) { for(int i=0;i<n;i++) ans = max(ans,confidence[i]); return ans; } return 0; }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:43:65: error: a function-definition is not allowed here before '{' token
   43 | int findSample(int n,int confidence[],int host[],int protocol[]){
      |                                                                 ^
friend.cpp:90:1: error: expected '}' at end of input
   90 | }
      | ^
friend.cpp:33:25: note: to match this '{'
   33 |                         {
      |                         ^
friend.cpp:40:6: warning: unused variable 'adj' [-Wunused-variable]
   40 | bool adj[10][10];
      |      ^~~
friend.cpp:91: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
friend.cpp:90:1: error: expected '}' at end of input
   90 | }
      | ^
friend.cpp:30:17: note: to match this '{'
   30 |                 {
      |                 ^
friend.cpp:28:21: warning: unused variable 'dbg' [-Wunused-variable]
   28 |                 int dbg = 0;
      |                     ^~~
friend.cpp:90:1: error: expected '}' at end of input
   90 | }
      | ^
friend.cpp:18:9: note: to match this '{'
   18 |         {
      |         ^
friend.cpp:90:1: error: expected '}' at end of input
   90 | }
      | ^
friend.cpp:8:65: note: to match this '{'
    8 | int findSample(int n,int confidence[],int host[],int protocol[]){
      |                                                                 ^
friend.cpp:90:1: warning: no return statement in function returning non-void [-Wreturn-type]
   90 | }
      | ^