Submission #941237

#TimeUsernameProblemLanguageResultExecution timeMemory
941237NumberzConnecting Supertrees (IOI20_supertrees)C++14
19 / 100
179 ms22356 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<std::vector<int>> p) { //subtask 1 int n = p.size(); vector<vector<int>> res(n, vector<int>(n, 0)); //checker vector<int> tracker(n, 0); vector<vector<int>> components; //checks if it is possible to build the bridges for (int i = 0; i < n; i++) { //checks if it should already be in a component bool search = true; for (int j = 0; j < components.size(); j++) { if (p[components[j][0]][i] == 2) { components[j].push_back(i); //cout << "prob first " << i << ' ' << j <<endl; //cout << "j: " << j << endl; tracker[i] = j; search = false; break; } } if (search) { components.push_back({i}); //cout << "prob second " << i << ' ' << components.size()-1 <<endl; //cout << "comps: " << components.size() << endl; tracker[i] = components.size()-1; } } //check if wrong for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { if ((tracker[i] == tracker[j] && p[i][j] == 0) || (tracker[i] != tracker[j] && p[i][j] != 0)) { return 0; } } } } //within each component, build a graph // size shoud be > 1 for (auto comp : components) { if (comp.size() > 1) { if (comp.size() == 2) { return 0; } int k = comp.size(); for (int i = 0; i < k-1; i++) { res[comp[i]][comp[i+1]] = 1; res[comp[i+1]][comp[i]] = 1; } res[comp[k-1]][comp[0]] = 1; res[comp[0]][comp[k-1]] = 1; } } build(res); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int j = 0; j < components.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...