제출 #1017841

#제출 시각아이디문제언어결과실행 시간메모리
1017841n3rm1n친구 (IOI14_friend)C++17
0 / 100
1076 ms3420 KiB
#include <bits/stdc++.h> #define endl '\n' #include "friend.h" using namespace std; vector < int > g[1005]; int cnt[4]; long long ans = 0, dp[1005], sum[1005]; void dfs(int beg) { // cout << beg << " " << sum[beg] << endl; dp[beg] = sum[beg]; int other = 0; int nb; for (int j = 0; j < g[beg].size(); ++ j) { nb = g[beg][j]; dfs(nb); other += dp[nb]; } dp[beg] = max(dp[beg], 1LL * other); ans = max(dp[beg], ans); // cout << "* " << beg << " " << dp[beg] << endl; } long long are[1005][1005], c[1005]; long long N, used[1005]; void check() { vector < int > g; long long all = 0; for (int i = 0; i < N; ++ i) { if(used[i]) { g.push_back(i); all += c[i]; } } for (int i = 0; i < g.size(); ++ i) { for (int j = i+1; j < g.size(); ++ j) if(are[g[i]][g[j]])return; } ans = max(ans, all); } void gen(int pos) { if(pos == N) { check(); return; } used[pos] = 0; gen(pos+1); used[pos] = 1; gen(pos+1); } int findSample(int n, int confidence[], int host[], int protocol[]) { N = n; if(n <= 10) { c[0] = confidence[0]; for (int i = 1; i < n; ++ i) { c[i] = confidence[i]; if(protocol[i] == 0) { are[i][host[i]] = 1; are[host[i]][i] = 1; } else { for (int j = 0; j < n; ++ j) { if(are[j][host[i]]) { are[i][j] = 1; are[j][i] = 1; } } if(protocol[i] == 2) { are[i][host[i]] = 1; are[host[i]][i] = 1; } } } gen(0); cout << ans << endl; } }

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

friend.cpp: In function 'void dfs(int)':
friend.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int j = 0; j < g[beg].size(); ++ j)
      |                     ~~^~~~~~~~~~~~~~~
friend.cpp: In function 'void check()':
friend.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < g.size(); ++ i)
      |                     ~~^~~~~~~~~~
friend.cpp:40:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int j = i+1; j < g.size(); ++ j)
      |                           ~~^~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:92:1: warning: no return statement in function returning non-void [-Wreturn-type]
   92 | }
      | ^
#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...