Submission #397718

#TimeUsernameProblemLanguageResultExecution timeMemory
397718ly20Split the Attractions (IOI19_split)C++17
18 / 100
105 ms13256 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 112345; bool vl = false; int resp[MAXN]; vector <int> grafo[MAXN]; int p1, p2; int N; int marc[MAXN]; int vz; void dfs2(int v) { vl = true; if(p1 > 0) { p1--; resp[v] = 1; } else { vz = v; return; } marc[v] = 1; for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] == 1) continue; dfs2(viz); } } void dfs3(int v) { vl = true; if(p2 > 0) { p2--; resp[v] = 2; } else return; marc[v] = 1; for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] == 1) continue; dfs3(viz); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { N = n; vector<int> res; int m = p.size(); p1 = a; p2 = b; for(int i = 0; i < m; i++) { int a1 = p[i], b1 = q[i]; grafo[a1].push_back(b1); grafo[b1].push_back(a1); } int id = 0, mn = n; for(int i = 0; i < n; i++) { if(grafo[i].size() < mn) { mn = grafo[i].size(); id = i; } } dfs2(id); dfs3(vz); for(int i = 0; i < n; i++) { if(vl && resp[i] == 0) resp[i] = 3; res.push_back(resp[i]); } return res; }

Compilation message (stderr)

split.cpp: In function 'void dfs2(int)':
split.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
split.cpp: In function 'void dfs3(int)':
split.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:54:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |         if(grafo[i].size() < mn) {
      |            ~~~~~~~~~~~~~~~~^~~~
#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...