Submission #404173

#TimeUsernameProblemLanguageResultExecution timeMemory
404173ly20Friend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int val[MAXN]; vector <int> grafo[MAXN]; // Find out best sample int ld[MAXN], mtc[MAXN]; void dfs(int v) { for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(ld[viz] != -1) continue; ld[viz] = 1 - ld[v]; dfs(viz); } } bool dfs1(int v) { for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] == 1) continue; marc[viz] = 1; if(mtc[viz] < 0 || dfs1(mtc[viz])) { mtc[viz] = v; mtc[v] = viz; return true; } } return false; } int findSample(int n,int confidence[],int host[],int protocol[]){ int tot = 0; int mx = 0; for(int i = 0; i < n; i++) { val[i] = confidence[i]; ld[i] = -1; mtc[i] = -1; } for(int i = 1; i < n; i++) { int cur = host[i]; if(protocol[i] == 0) { grafo[i].push_back(cur); grafo[cur].push_back(i); } else { for(int j = 0; j < grafo[cur].size(); j++) { int viz = grafo[cur][j]; grafo[viz].push_back(i); grafo[i].push_back(viz); } } } for(int i = 0; i < n; i++) { if(ld[i] == -1) { ld[i] = 0; dfs(i); } } bool aux = true; int resp = 0; while(aux) { for(int i = 0; i < n; i++) { marc[i] = 0; } aux = false; for(int i = 0; i < n; i++) { if(ld[i] == 1) continue; if(dfs1(i)) { resp++; aux = true; } } } return resp; }

Compilation message (stderr)

friend.cpp: In function 'void dfs(int)':
friend.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
friend.cpp: In function 'bool dfs1(int)':
friend.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
friend.cpp:21:12: error: 'marc' was not declared in this scope
   21 |         if(marc[viz] == 1) continue;
      |            ^~~~
friend.cpp:22:9: error: 'marc' was not declared in this scope
   22 |         marc[viz] = 1;
      |         ^~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:46:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for(int j = 0; j < grafo[cur].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~~~~
friend.cpp:63:13: error: 'marc' was not declared in this scope
   63 |             marc[i] = 0;
      |             ^~~~
friend.cpp:32:9: warning: unused variable 'tot' [-Wunused-variable]
   32 |     int tot = 0;
      |         ^~~
friend.cpp:33:9: warning: unused variable 'mx' [-Wunused-variable]
   33 |     int mx = 0;
      |         ^~