제출 #622383

#제출 시각아이디문제언어결과실행 시간메모리
622383happypotato슈퍼트리 잇기 (IOI20_supertrees)C++17
11 / 100
1193 ms1871404 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back // const int mxN = 1001; vector<vector<int>> paths; int n; bool st1() { vector<vector<int>> ans; ans.resize(n); for (int i = 0; i < n; i++) ans[i].resize(n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ans[i][j] = (abs(i - j) == 1); } } build(ans); return true; } bool vis[mxN]; void resetvis() { for (int i = 0; i < n; i++) vis[i] = false; } vector<vector<int>> components; vector<int> curcomponent; void dfs(int u, int tar) { curcomponent.pb(u); vis[u] = true; for (int v = 0; v < n; v++) { if (u != v && 1 <= paths[u][v] && paths[u][v] <= tar) { dfs(v, tar); } } } int rep[mxN]; int repcnt = 1; bool fullsol() { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (paths[i][j] == 3) return false; } } for (int i = 0; i < n; i++) { if (!vis[i]) { dfs(i, 2); components.pb(curcomponent); curcomponent.clear(); } } vector<vector<int>> ans(n); for (int i = 0; i < n; i++) ans[i].resize(n, 0); vector<vector<int>> decomp; for (vector<int> &cur : components) { decomp.clear(); for (int &u : cur) { for (int &v : cur) { if (!vis[u] && paths[u][v] == 1) { dfs(u, 1); for (int &x : curcomponent) rep[x] = repcnt; repcnt++; decomp.pb(curcomponent); curcomponent.clear(); break; } } if (!vis[u]) decomp.pb({u}); } for (int &u : cur) { for (int &v : cur) { if (paths[u][v] != 1 + (rep[u] != rep[v])) return false; } } for (vector<int> &process : decomp) { for (int i = 1; i < process.size(); i++) { ans[process[i - 1]][process[i]] = 1; } } if (decomp.size() >= 2) { for (int i = 1; i < decomp.size(); i++) { ans[decomp[i - 1][0]][decomp[i][0]] = 1; } ans[decomp.front()[0]][decomp.back()[0]] = 1; } } build(ans); return true; } int construct(vector<vector<int>> p) { n = p.size(); paths = p; int st = 0; for (vector<int> &curv : p) { for (int &cur : curv) { st |= (1 << cur); } } if (st == 2) return st1(); else return fullsol(); }

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

supertrees.cpp: In function 'bool fullsol()':
supertrees.cpp:79:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             for (int i = 1; i < process.size(); i++) {
      |                             ~~^~~~~~~~~~~~~~~~
supertrees.cpp:84:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |             for (int i = 1; i < decomp.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...