Submission #404176

#TimeUsernameProblemLanguageResultExecution timeMemory
404176ly20Friend (IOI14_friend)C++17
0 / 100
1 ms332 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int val[MAXN], marc[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[]){ 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 n - 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: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:44:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             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...