Submission #313560

#TimeUsernameProblemLanguageResultExecution timeMemory
313560mohamedsobhi777Connecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h" #include <bits/stdc++.h> #include <vector> using namespace std; std::vector<std::vector<int>> answer, p ; int vis[100000]; bool bad; int nn; vector<int> vecs(int x) { vector<int> ret; queue<int> qu; qu.push(x); while (qu.size()) { int x = qu.front(); qu.pop(); if (vis[x]++) continue; ret.push_back(x); for (int i = 0; i < n; ++i) { if (i == x || vis[i] || !p[x][i]) continue; qu.push(i); } } return ret; } void solve(vector<int> vecs) { if (!vecs.size()) return; int sz = (int)vecs.size(); vector<int> cycle, line; for (int i = 0; i < sz; ++i) { for (int j = 0; j < sz; ++j) { if (i == j) continue; if (p[vecs[i]][vecs[j]] != 2) { line.push_back(i); break; } } if (line.empty() || line.back() != i) cycle.push_back(i); } if (cycle.size() == 1) bad = 1; if (line.size() && cycle.size()) cycle.push_back(line[0]); for (int i = 0; i < (int)cycle.size(); ++i) { } for (int i = 1; i < (int)line.size(); ++i) { int x = vecs[line[i]], y = vecs[line[i - 1]]; answer[x][y] = answer[y][x] = 1; } for (int i = 0; i < line.size(); ++i) { for (int j = 0; j < line.size(); ++j) { if (i == j) continue; if (p[vecs[i]][vecs[j]] != 1) bad = 1; } } } int construct(std::vector<std::vector<int>> P) { p = P ; nn = p.size(); for (int i = 0; i < nn; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } for (int i = 0; i < nn; ++i) { vector<int> g = vecs(i); solve(g); } if (bad) return 0; build(answer); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'std::vector<int> vecs(int)':
supertrees.cpp:24:37: error: 'n' was not declared in this scope
   24 |                 for (int i = 0; i < n; ++i)
      |                                     ^
supertrees.cpp: In function 'void solve(std::vector<int>)':
supertrees.cpp:67:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for (int i = 0; i < line.size(); ++i)
      |                         ~~^~~~~~~~~~~~~
supertrees.cpp:69:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |                 for (int j = 0; j < line.size(); ++j)
      |                                 ~~^~~~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:86:28: error: 'n' was not declared in this scope
   86 |                 row.resize(n);
      |                            ^