제출 #770999

#제출 시각아이디문제언어결과실행 시간메모리
770999OrazB슈퍼트리 잇기 (IOI20_supertrees)C++17
11 / 100
159 ms24296 KiB
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; #define N 100005 #define wr cout << "Continue debugging\n"; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second vector<int> vec[N]; // int find(int i, vector<vector<int>> p, int n){ // set<int> s; // for (int j = 0; j < n; j++){ // if (p[i][j] and i != j) s.insert(p[i][j]); // } // if (s.size() > 1) return -1; // if (!s.size()) return -2; // return *s.begin(); // } int construct(vector<vector<int>> p){ int n = p.size(); vector<vector<int>> b(n, vector<int>(n, 0)); vector<int> vis(n, 0); int cnt = 0; for (int i = 0; i < n; i++){ if (!vis[i]) vis[i] = ++cnt; for (int j = 0; j < n; j++){ if (p[i][j] and i != j) vis[j] = vis[i]; else if (!p[i][j]) vec[vis[i]].pb(j); } // if (x == 2){ // int a1 = -1, b1 = -1; // for (int j = 0; j < n; j++){ // if (p[i][j] and i != j){ // if (a1 == -1) a1 = j; // else b1 = j; // } // } // if (b1 == -1) return 0; // b[a1][b1] = b[b1][a1] = 1; // } } for (int i = 0; i < n; i++){ for (auto j : vec[vis[i]]){ if (p[i][j]) return 0; } } vector<int> chk(n, 0); for (int i = 0; i < n; i++){ if (chk[vis[i]]++) continue; for (int j = 0; j < n; j++){ if (p[i][j] and i != j) b[i][j] = b[j][i] = 1; } } // for (int i = 0; i < n; i++){ // for (int j = 0; j < n; j++) cout << b[i][j] << ' '; // cout << '\n'; // } build(b); return 1; } // int main () // { // int n; // cin >> n; // vector<vector<int>> p(n, vector<int>(n)); // for (int i = 0; i < n; i++){ // for (int j = 0; j < n; j++) cin >> p[i][j]; // } // int x = construct(p); // }
#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...