Submission #1084740

#TimeUsernameProblemLanguageResultExecution timeMemory
1084740an22inkleConnecting Supertrees (IOI20_supertrees)C++17
11 / 100
136 ms24148 KiB
#include<bits/stdc++.h> #include "supertrees.h" using pair = std::array<int, 2>; using ll = long long; int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> ans(n, std::vector<int>(n)), lines; std::vector<int> part(n, -1); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; if (p[i][j] == 0 || (part[i] > -1 && part[j] > -1)) continue; if (part[i] > -1) lines[part[i]].push_back(j), part[j] = part[i]; else if (part[j] > -1) lines[part[j]].push_back(i), part[i] = part[j]; else { lines.push_back({}); lines.back().push_back(i); lines.back().push_back(j); part[i] = part[j] = lines.size() - 1; } } } for (auto line : lines) { for (int i = 0; i < line.size(); i++) { for (int j = i+1; j < line.size(); j++) { if (p[line[i]][line[j]] == 0) return 0; } // std::cout << line[i] << ' '; if (i != line.size() - 1) ans[line[i]][line[i+1]] = ans[line[i + 1]][line[i]] = 1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for (int i = 0; i < line.size(); i++) {
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for (int j = i+1; j < line.size(); j++) {
      |                      ~~^~~~~~~~~~~~~
supertrees.cpp:32:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if (i != line.size() - 1) ans[line[i]][line[i+1]] = ans[line[i + 1]][line[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...