Submission #394487

#TimeUsernameProblemLanguageResultExecution timeMemory
394487koste4kaConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1 ms332 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } vector < int > col; vector < bool > u(n); vector < int > now; vector < vector < int > > all; int cur = 0; for (int i = 0; i < n; ++i) { if (u[i]) { continue; } ++cur; now.clear(); for (int j = i; j < n; ++j) { if (u[j] || p[i][j] != 1) { continue; } now.push_back(j); u[j] = 1; } for (auto j : now) { col[cur] = 1; } for (auto v : now) { for (auto u : now) { if (p[v][u] != 1) { return 0; } } } for (int j = 1; j < (int)(now.size()); ++j) { answer[now[j - 1]][now[j]] = 1; answer[now[j]][now[j - 1]] = 1; } all.push_back(now); } for (int i = 0; i < (int)(all.size()); ++i) { for (auto v : all[i]) { for (int j = 0; j < n; ++j) { if (p[v][j] != p[all[i][0]][j]) { return 0; } } } } int last; for (int i = 0; i < n; ++i) { u[i] = 0; } for (int i = 0; i < (int)(all.size()); ++i) { if (u[i]) { continue; } last = all[i].back(); for (int j = i + 1; j < (int)(all.size()); ++j) { if (!u[j] && p[last][all[j].back()] == 2) { answer[last][all[j].back()] = 1; answer[all[j].back()][last] = 1; last = all[j].back(); u[j] = 1; } } if (last != all[i].back()) { answer[last][all[i].back()] = 1; answer[all[i].back()][last] = 1; } } build(answer); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:32:19: warning: unused variable 'j' [-Wunused-variable]
   32 |         for (auto j : now) {
      |                   ^
#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...