제출 #424224

#제출 시각아이디문제언어결과실행 시간메모리
424224Charis02친구 (IOI14_friend)C++14
19 / 100
1 ms460 KiB
#include "friend.h" #include<iostream> #include<vector> #include<string.h> #define rep(i,a,b) for(int i = a;i < b;i++) #define N 1004 using namespace std; vector < int > graph[N]; int conf[N]; int id[N]; int dp[N][2]; int calc(int cur,int par,int choose) { int res = 0; if(dp[cur][choose]!=-1) return dp[cur][choose]; if(choose) { res = conf[cur]; rep(i,0,graph[cur].size()) { int v = graph[cur][i]; if(v == par) continue; res += calc(v,cur,0); } } else { rep(i,0,graph[cur].size()) { int v = graph[cur][i]; if(v == par) continue; res += max(calc(v,cur,0),calc(v,cur,1)); } } return dp[cur][choose] = res; } int findSample(int n,int confidence[],int host[],int protocol[]) { rep(i,0,n) id[i] = i; rep(i,0,n) { conf[i] = confidence[i]; if(i == 0) continue; if(protocol[i] == 0) { graph[id[host[i]]].push_back(id[i]); graph[id[i]].push_back(id[host[i]]); } else { id[i] = host[i]; conf[host[i]]++; } } memset(dp,-1,sizeof dp); return max(calc(1,1,0),calc(1,1,1)); }

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

friend.cpp: In function 'int calc(int, int, int)':
friend.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = a;i < b;i++)
......
   26 |         rep(i,0,graph[cur].size())
      |             ~~~~~~~~~~~~~~~~~~~~~   
friend.cpp:26:9: note: in expansion of macro 'rep'
   26 |         rep(i,0,graph[cur].size())
      |         ^~~
friend.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for(int i = a;i < b;i++)
......
   37 |         rep(i,0,graph[cur].size())
      |             ~~~~~~~~~~~~~~~~~~~~~   
friend.cpp:37:9: note: in expansion of macro 'rep'
   37 |         rep(i,0,graph[cur].size())
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...