Submission #769089

#TimeUsernameProblemLanguageResultExecution timeMemory
769089t6twotwoConnecting Supertrees (IOI20_supertrees)C++17
19 / 100
160 ms24088 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(std::vector<std::vector<int>> a) { int N = a.size(); vector<vector<int>> s(N); vector<bool> vis(N); for (int i = 0; i < N; i++) { if (vis[i]) { continue; } vis[i] = 1; queue<int> q; q.push(i); while (!q.empty()) { int x = q.front(); q.pop(); s[i].push_back(x); for (int y = 0; y < N; y++) { if (!vis[y] && a[x][y]) { vis[y] = 1; q.push(y); } } } } vector ans(N, vector<int>(N)); for (auto &v : s) { if (v.size() <= 1) { continue; } if (v.size() == 2) { return 0; } for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { if (!a[v[i]][v[j]]) { return 0; } } } for (int i = 0; i < v.size(); i++) { int x = v[i]; int y = v[i + 1 == v.size() ? 0 : i + 1]; ans[x][y] = ans[y][x] = 1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
supertrees.cpp:36:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for (int j = i + 1; j < v.size(); j++) {
      |                                 ~~^~~~~~~~~~
supertrees.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
supertrees.cpp:44:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             int y = v[i + 1 == v.size() ? 0 : i + 1];
      |                       ~~~~~~^~~~~~~~~~~
#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...