제출 #576692

#제출 시각아이디문제언어결과실행 시간메모리
576692Vanilla슈퍼트리 잇기 (IOI20_supertrees)C++17
46 / 100
247 ms24048 KiB
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; const int maxn = 1002; int d[maxn]; int dad (int x) { return d[x] = (x == d[x] ? x: dad(d[x])); } void merge (int a, int b){ a = dad(a); b = dad(b); d[b] = a; } int construct(vector<vector<int>> p) { int n = p.size(); vector <vector <int> > b (n, vector <int> (n, 0)); for (int i = 0; i < n; i++){ d[i] = i; } for (int i = 0; i < n; i++){ for (int j = i + 1; j < n; j++){ if (p[i][j] == 3) return 0; if (p[i][j] == 1 && dad(i) != dad(j)) { b[i][j] = b[j][i] = 1; merge(i,j); } } } for (int i = 0; i < n; i++){ vector <int> v; v.push_back(dad(i)); for (int j = i + 1; j < n; j++){ if (p[i][j] == 2 && dad(i) != dad(j)) { v.push_back(dad(j)); merge(i, j); } } // if (v.size() == 2) return 0; for (int i = 0; i < v.size(); i++){ int p1 = v[i], p2 = v[(i + 1) % v.size()]; b[p1][p2] = b[p2][p1] = 1; // cout << p1 << " " << p2 << "\n"; } } for (int i = 0; i < n; i++){ b[i][i] = 0; // for (int j = i + 1; j < n; j++){ // if (b[i][j]) { // cout << i << " " << j << "\n"; // } // } } build(b); return 1; }

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

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