제출 #151704

#제출 시각아이디문제언어결과실행 시간메모리
151704willi19친구 (IOI14_friend)C++14
컴파일 에러
0 ms0 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; int c[100100],h[100100],p[100100],edge[12][12],dp[11000]; int ans(int state) { if(!dp[state]) return dp[state]; int ret=0; for(int i=0;i<n;i++) if(state&(1<<i)) ret+=c[i]; for(int i=0;i<n;i++) { if((state&(1<<i))==1) continue; bool pos=true; for(int j=0;j<n;j++) if(edge[i][j]==1) pos=false; if(pos) ret=max(ret,ans(state|(1<<i))); } dp[state]=ret; return ret; } int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=0;i<n;i++) { c[i]=confidence[i]; h[i]=host[i]; p[i]=protocol[i]; } for(int i=1;i<=n;i++) { if(p[i]==0) edge[i][h[i]]=edge[h[i]][i]=1; else { for(int j=0;j<n;j++) edge[i][j]=edge[h[i]][j]; if(p[i]==2) edge[i][host[i]]=edge[host[i]][i]=1; } } cout<<ans(0); }

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'int ans(int)':
friend.cpp:10:19: error: 'n' was not declared in this scope
     for(int i=0;i<n;i++)
                   ^
friend.cpp:13:19: error: 'n' was not declared in this scope
     for(int i=0;i<n;i++)
                   ^
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:47:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^