제출 #715742

#제출 시각아이디문제언어결과실행 시간메모리
715742n1k슈퍼트리 잇기 (IOI20_supertrees)C++17
21 / 100
190 ms28040 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define sz(a) (a).size() vector<vector<int>> components; vector<bool> vis; std::vector<std::vector<int>> adj; int n; bool dfs(int u){ vis[u] = 1; // u connectet to all in component for(auto v : components[sz(components) - 1]){ if(!adj[v][u]){ return false; } } components[sz(components) - 1].push_back(u); for(int v = 0; v < n; v++){ if(vis[v]){ continue; } if(adj[u][v]){ if(!dfs(v)){ return false; } } } return true; } int construct(std::vector<std::vector<int>> p) { adj = p; n = p.size(); vis.resize(n); // p[i][j] = 1 -> same component // p[j][k] = 1 -> p[i][k] = 1 // add j // j -> has connection to all in component // dfs -> j for(int u = 0; u < n; u++){ if(vis[u]){ continue; } components.push_back(vector<int>()); if(!dfs(u)){ return 0; } } vector<vector<int>> mat(n, vector<int>(n)); for(auto comp : components){ for(int i = 0; i < sz(comp) - 1; i++){ mat[comp[i]][comp[i + 1]] = 1; mat[comp[i + 1]][comp[i]] = 1; } } build(mat); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for(int i = 0; i < sz(comp) - 1; i++){
      |                  ~~^~~~~~~~~~~~~~
#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...