Submission #404154

#TimeUsernameProblemLanguageResultExecution timeMemory
404154ly20Friend (IOI14_friend)C++17
0 / 100
65 ms25448 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int marc[MAXN]; int val[MAXN]; vector <int> grafo[MAXN]; // Find out best sample int br, pt; void dfs(int v) { if(marc[v] == 0) br += val[v]; else pt += val[v]; for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] != -1) { continue; } marc[viz] = 1 - marc[v]; dfs(viz); } } int dp[MAXN][2]; int findSample(int n,int confidence[],int host[],int protocol[]){ int tot = 0; int mx = 0; for(int i = 0; i < n; i++) { marc[i] = -1; val[i] = confidence[i]; mx = max(mx, val[i]); } for(int i = 1; i < n - 1; i++) { int cur = host[i]; if(protocol[i] == 0 || protocol[i] == 2) { grafo[i].push_back(cur); grafo[cur].push_back(i); } if(protocol[i] == 1 || protocol[i] == 2) { for(int j = 0; j < grafo[cur].size(); j++) { int viz = grafo[cur][j]; grafo[i].push_back(viz); grafo[viz].push_back(i); } } } int resp = 0; for(int i = 0; i < n; i++) { if(marc[i] == -1) { br = 0; pt = 0; marc[i] = 0; dfs(i); resp += max(br, pt); tot += br + pt; } } dp[0][1] = val[0]; dp[0][0] = 0; for(int i = 1; i < n; i++) { dp[i][0] = max(dp[i - 1][0] , dp[i - 1][1]); dp[i][1] = dp[i - 1][0] + val[i]; } return max(dp[n - 1][0], dp[n - 1][1]); }

Compilation message (stderr)

friend.cpp: In function 'void dfs(int)':
friend.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j = 0; j < grafo[cur].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~~~~
#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...