Submission #404153

#TimeUsernameProblemLanguageResultExecution timeMemory
404153ly20Friend (IOI14_friend)C++17
8 / 100
2 ms336 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 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; } } return mx; }

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++) {
      |                    ~~^~~~~~~~~~~~~~~~~
#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...