Submission #1087035

#TimeUsernameProblemLanguageResultExecution timeMemory
1087035SulAConnecting Supertrees (IOI20_supertrees)C++17
11 / 100
128 ms32292 KiB
#include "supertrees.h" #include <iostream> #include <vector> using namespace std; vector<int> adj[1000], comp; bool visited[1000]; void dfs(int u) { comp.push_back(u); visited[u] = -true; for (int v: adj[u]) if (!visited[v]) { dfs(v); } } int construct(vector<vector<int>> p) { int n = p.size(), mx = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { mx = max(mx, p[i][j]); if (p[i][j] != 0) { adj[i].push_back(j); adj[j].push_back(i); } } } vector<vector<int>> adj(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) if (!visited[i]) { comp.clear(); dfs(i); for (int j = 0; j < comp.size() - 1; j++) { adj[ comp[j] ][ comp[j+1] ] = adj[ comp[j+1] ][ comp[j] ] = 1; } if (mx == 2) { if (comp.size() < 3) return 0; adj[comp.front()][comp.back()] = adj[comp.back()][comp.front()] = 1; } } build(adj); return 1; }

Compilation message (stderr)

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