제출 #478394

#제출 시각아이디문제언어결과실행 시간메모리
478394ponytail슈퍼트리 잇기 (IOI20_supertrees)C++17
56 / 100
279 ms24060 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int dsu[1000]; int dsu2[1000]; int set_of(int u) { if(dsu[u] == u) return u; return dsu[u] = set_of(dsu[u]); } void union_(int u, int v) { dsu[set_of(u)] = set_of(v); } int set_of2(int u) { if(dsu2[u] == u) return u; return dsu2[u] = set_of2(dsu2[u]); } void union2(int u, int v) { dsu2[set_of2(u)] = set_of2(v); } 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); } for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(p[i][j] == 3) return 0; } } for(int i=0; i<n; i++) { dsu[i] = dsu2[i] = i; } vector<vector<int> > v(n); for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(p[i][j] == 1) { if(set_of(i) != set_of(j)) { union_(i, j); answer[i][j] = answer[j][i] = 1; } } } } for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(p[i][j] != 1 && set_of(i) == set_of(j)) { return 0; } } } vector<int> fin; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(p[i][j] == 2 && set_of(i) != set_of(j)) { union2(set_of(i), set_of(j)); } } } for(int i=0; i<n; i++) { v[set_of2(i)].push_back(i); } for(int i=0; i<n; i++) { if(v[i].size() == 2) return 0; } for(int i=0; i<n; i++) { if(v[i].size() > 2) { for(int j=0; j<v[i].size(); j++) { answer[v[i][j]][v[i][(j+1) % v[i].size()]] = 1; answer[v[i][(j+1) % v[i].size()]][v[i][j]] = 1; union_(v[i][j], v[i][(j+1) % v[i].size()]); } } } build(answer); return 1; }

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

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