제출 #1061870

#제출 시각아이디문제언어결과실행 시간메모리
1061870ArthuroWich슈퍼트리 잇기 (IOI20_supertrees)C++17
100 / 100
140 ms28028 KiB
#include "supertrees.h" #include<bits/stdc++.h> using namespace std; vector<vector<int>> adj; int n, vis[1005], used[1005], co = 0; void dfs(int i) { if (vis[i] > 0) { return; } vis[i] = co; for (int j = 0; j < n; j++) { if (i == j || adj[i][j] == 0) { continue; } dfs(j); } } int construct(vector<vector<int>> p) { n = p.size(); adj = p; vector<vector<int>> ans(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) { if (vis[i] > 0) { continue; } co++; dfs(i); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] == 3) { return 0; } if (p[i][j] == 0) { if (vis[i] == vis[j]) { return 0; } } else { if (vis[i] != vis[j]) { return 0; } } } } for (int i = 1; i <= co; i++) { vector<int> root; for (int j = 0; j < n; j++) { if (vis[j] == i && !used[j]) { root.push_back(j); used[j] = 1; for (int k = 0; k < n; k++) { if (k == j) { continue; } if (p[j][k] == 1) { used[k] = 1; ans[j][k] = 1; ans[k][j] = 1; } } } } if (root.size() == 1) { continue; } if (root.size() < 3) { return 0; } for (int j = 1; j < root.size(); j++) { ans[root[j]][root[j-1]] = 1; ans[root[j-1]][root[j]] = 1; } ans[root.front()][root.back()] = 1; ans[root.back()][root.front()] = 1; } build(ans); return 1; }

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

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