#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#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
const int N = 1e3+5;
int T, vis[N][N], cur[N], tp[N];
vector<vector<int>> b;
set<int> A[N], B[N];
vector<int> E[N];
int F1(int n, int i, vector<vector<int>> p){
if (A[cur[i]].find(i) != A[cur[i]].end()) return p[tp[i]] == p[i];
for (int j = 0; j < n; j++){
if (i == j) continue;
if (vis[cur[i]][j] != (p[i][j] == 0)) return 0;
if (p[i][j] == 1){
tp[j] = i;
A[cur[i]].insert(j);
B[cur[i]].erase(j);
b[i][j] = b[j][i] = 1;
}
}
return 1;
}
void F2(int n, int i, vector<vector<int>> p){
++T;
B[T].insert(i);
for (int j = 0; j < n; j++){
if (i == j) continue;
if (p[i][j] == 0) vis[T][j] = 1;
else{
cur[j] = T;
if (p[i][j] == 1){
tp[j] = i;
A[T].insert(j);
b[i][j] = b[j][i] = 1;
}else B[T].insert(j);
}
}
}
int construct(vector<vector<int>> p){
int n = p.size();
b.resize(n);
for (int i = 0; i < n; i++){
b[i].resize(n);
if (count(all(p[i]), 3)) return 0;
if (cur[i]){
int x = F1(n, i, p);
if (!x) return 0;
}else F2(n, i, p);
}
for (int i = 1; i <= T; i++){
int lst = *B[i].rbegin();
for (auto j : B[i]){
b[lst][j] = b[j][lst] = 1;
lst = j;
}
}
build(b);
return 1;
}
// int main ()
// {
// ios::sync_with_stdio(false);
// cin.tie(0);
// 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];
// }
// cout << construct(p);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |