Submission #601070

#TimeUsernameProblemLanguageResultExecution timeMemory
601070FatihSolakConnecting Supertrees (IOI20_supertrees)C++17
21 / 100
228 ms24016 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define N 1005 using namespace std; int construct(vector<vector<int>> p){ int n = p.size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); answer.push_back(row); } vector<bool> vis(n); for(int i = 0;i<n;i++){ if(!vis[i]){ vector<bool> vis2(n); vector<bool> cur(n); vector<int> now; for(int j = 0;j<n;j++){ if(p[i][j]){ vis[j] = 1; cur[j] = 1; now.push_back(j); } } for(auto u:now){ for(int j = 0;j<n;j++){ if(!!p[u][j] != cur[j]){ return 0; } } } vector<int> circle; vector<int> par_on_circle(n); for(auto u:now){ if(vis2[u])continue; circle.push_back(u); for(int j = 0;j<n;j++){ if(p[u][j] == 1){ par_on_circle[j] = u; vis2[j] = 1; if(u != j){ answer[u][j] = answer[j][u] = 1; } } } } for(auto u:now){ for(auto c:now){ if(p[u][c] != 2 - par_on_circle[u] == par_on_circle[c]){ return 0; } } } int sz = circle.size(); if(sz != 1){ for(int j = 0;j<sz;j++){ answer[circle[j]][circle[(j+1)%sz]] = answer[circle[(j+1)%sz]][circle[j]] = 1; } } } } build(answer); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:51:17: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]
   51 |      if(p[u][c] != 2 - par_on_circle[u] == par_on_circle[c]){
#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...