#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;}
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "supertrees.h"
struct DSU{
vector<int> par;
DSU(int n){
par.resize(n);
iota(par.begin(), par.end(), 0ll);
}
int find(int node){
if (par[node]==node) return node;
return par[node]=find(par[node]);
}
void merge(int a, int b){
a=find(a);
b=find(b);
if (ayahya()%2) swap(a,b);
par[a]=b;
}
};
int construct(vector<vector<int>> p){
int n = p.size();
for (int i = 0; i < n; ++i)
{
if (p[i][i]!=1) return 0;
}
DSU glob(n);
DSU dal(n);
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (p[i][j]!=p[j][i]) return 0;
if (p[i][j]) glob.merge(i,j);
else if (glob.find(i)==glob.find(j)) return 0;
if (p[i][j]==1) dal.merge(i,j);
else if (dal.find(i)==dal.find(j)) return 0;
}
}
vector<vector<int>> els(n);
vector<vector<int>> els2(n);
for (int i = 0; i < n; ++i)
{
els[dal.find(i)].push_back(i);
if (dal.find(i)==i){
els2[glob.find(i)].push_back(i);
}
}
vector<vector<int>> rval(n,vector<int>(n,0));
for (int i = 0; i < n; ++i)
{
if (els2[i].size()==2) return 0;
for (int j = 0; j < els2[i].size(); j++){
int x = els2[i][j];
int y = els2[i][(j+1)%els2[i].size()];
if (x==y) continue;
rval[x][y]=1;
rval[y][x]=1;
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 1; j < els[i].size(); j++){
int x = els[i][j];
int y = els[i][j-1];
if (x==y) continue;
rval[x][y]=1;
rval[y][x]=1;
}
}
build(rval);
return 1;
}
Compilation message
supertrees.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:84:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | for (int j = 0; j < els2[i].size(); j++){
| ~~^~~~~~~~~~~~~~~~
supertrees.cpp:94:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
94 | for (int j = 1; j < els[i].size(); j++){
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
10 ms |
1136 KB |
Output is correct |
7 |
Correct |
198 ms |
22024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
10 ms |
1136 KB |
Output is correct |
7 |
Correct |
198 ms |
22024 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1108 KB |
Output is correct |
13 |
Correct |
153 ms |
22168 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
596 KB |
Output is correct |
17 |
Correct |
79 ms |
8072 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
43 ms |
5768 KB |
Output is correct |
21 |
Correct |
168 ms |
22072 KB |
Output is correct |
22 |
Correct |
193 ms |
22024 KB |
Output is correct |
23 |
Correct |
181 ms |
22076 KB |
Output is correct |
24 |
Correct |
165 ms |
22132 KB |
Output is correct |
25 |
Correct |
106 ms |
8140 KB |
Output is correct |
26 |
Correct |
70 ms |
8140 KB |
Output is correct |
27 |
Correct |
204 ms |
22040 KB |
Output is correct |
28 |
Correct |
192 ms |
22092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
1236 KB |
Output is correct |
9 |
Correct |
150 ms |
24052 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
10 ms |
1224 KB |
Output is correct |
13 |
Correct |
172 ms |
24056 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
704 KB |
Output is correct |
17 |
Correct |
75 ms |
10104 KB |
Output is correct |
18 |
Correct |
1 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
42 ms |
6224 KB |
Output is correct |
22 |
Correct |
183 ms |
24024 KB |
Output is correct |
23 |
Correct |
168 ms |
24080 KB |
Output is correct |
24 |
Correct |
204 ms |
24056 KB |
Output is correct |
25 |
Correct |
84 ms |
14080 KB |
Output is correct |
26 |
Correct |
72 ms |
10104 KB |
Output is correct |
27 |
Correct |
160 ms |
24056 KB |
Output is correct |
28 |
Correct |
252 ms |
24056 KB |
Output is correct |
29 |
Correct |
79 ms |
14284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
59 ms |
5716 KB |
Output is correct |
5 |
Correct |
173 ms |
21996 KB |
Output is correct |
6 |
Correct |
171 ms |
22148 KB |
Output is correct |
7 |
Correct |
188 ms |
22032 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
47 ms |
5796 KB |
Output is correct |
10 |
Correct |
161 ms |
22092 KB |
Output is correct |
11 |
Correct |
176 ms |
22084 KB |
Output is correct |
12 |
Correct |
188 ms |
22032 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
45 ms |
5776 KB |
Output is correct |
17 |
Correct |
165 ms |
22108 KB |
Output is correct |
18 |
Correct |
169 ms |
22024 KB |
Output is correct |
19 |
Correct |
155 ms |
22032 KB |
Output is correct |
20 |
Correct |
157 ms |
22120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
10 ms |
1136 KB |
Output is correct |
7 |
Correct |
198 ms |
22024 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1108 KB |
Output is correct |
13 |
Correct |
153 ms |
22168 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
596 KB |
Output is correct |
17 |
Correct |
79 ms |
8072 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
43 ms |
5768 KB |
Output is correct |
21 |
Correct |
168 ms |
22072 KB |
Output is correct |
22 |
Correct |
193 ms |
22024 KB |
Output is correct |
23 |
Correct |
181 ms |
22076 KB |
Output is correct |
24 |
Correct |
165 ms |
22132 KB |
Output is correct |
25 |
Correct |
106 ms |
8140 KB |
Output is correct |
26 |
Correct |
70 ms |
8140 KB |
Output is correct |
27 |
Correct |
204 ms |
22040 KB |
Output is correct |
28 |
Correct |
192 ms |
22092 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
7 ms |
1236 KB |
Output is correct |
37 |
Correct |
150 ms |
24052 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
10 ms |
1224 KB |
Output is correct |
41 |
Correct |
172 ms |
24056 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
4 ms |
704 KB |
Output is correct |
45 |
Correct |
75 ms |
10104 KB |
Output is correct |
46 |
Correct |
1 ms |
308 KB |
Output is correct |
47 |
Correct |
0 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
42 ms |
6224 KB |
Output is correct |
50 |
Correct |
183 ms |
24024 KB |
Output is correct |
51 |
Correct |
168 ms |
24080 KB |
Output is correct |
52 |
Correct |
204 ms |
24056 KB |
Output is correct |
53 |
Correct |
84 ms |
14080 KB |
Output is correct |
54 |
Correct |
72 ms |
10104 KB |
Output is correct |
55 |
Correct |
160 ms |
24056 KB |
Output is correct |
56 |
Correct |
252 ms |
24056 KB |
Output is correct |
57 |
Correct |
79 ms |
14284 KB |
Output is correct |
58 |
Correct |
1 ms |
212 KB |
Output is correct |
59 |
Correct |
1 ms |
308 KB |
Output is correct |
60 |
Correct |
4 ms |
596 KB |
Output is correct |
61 |
Correct |
74 ms |
10100 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
1 ms |
212 KB |
Output is correct |
64 |
Correct |
1 ms |
212 KB |
Output is correct |
65 |
Correct |
40 ms |
6268 KB |
Output is correct |
66 |
Correct |
78 ms |
10100 KB |
Output is correct |
67 |
Correct |
89 ms |
10100 KB |
Output is correct |
68 |
Correct |
82 ms |
10060 KB |
Output is correct |
69 |
Correct |
82 ms |
14196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
10 ms |
1136 KB |
Output is correct |
7 |
Correct |
198 ms |
22024 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1108 KB |
Output is correct |
13 |
Correct |
153 ms |
22168 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
596 KB |
Output is correct |
17 |
Correct |
79 ms |
8072 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
43 ms |
5768 KB |
Output is correct |
21 |
Correct |
168 ms |
22072 KB |
Output is correct |
22 |
Correct |
193 ms |
22024 KB |
Output is correct |
23 |
Correct |
181 ms |
22076 KB |
Output is correct |
24 |
Correct |
165 ms |
22132 KB |
Output is correct |
25 |
Correct |
106 ms |
8140 KB |
Output is correct |
26 |
Correct |
70 ms |
8140 KB |
Output is correct |
27 |
Correct |
204 ms |
22040 KB |
Output is correct |
28 |
Correct |
192 ms |
22092 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
7 ms |
1236 KB |
Output is correct |
37 |
Correct |
150 ms |
24052 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
10 ms |
1224 KB |
Output is correct |
41 |
Correct |
172 ms |
24056 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
4 ms |
704 KB |
Output is correct |
45 |
Correct |
75 ms |
10104 KB |
Output is correct |
46 |
Correct |
1 ms |
308 KB |
Output is correct |
47 |
Correct |
0 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
42 ms |
6224 KB |
Output is correct |
50 |
Correct |
183 ms |
24024 KB |
Output is correct |
51 |
Correct |
168 ms |
24080 KB |
Output is correct |
52 |
Correct |
204 ms |
24056 KB |
Output is correct |
53 |
Correct |
84 ms |
14080 KB |
Output is correct |
54 |
Correct |
72 ms |
10104 KB |
Output is correct |
55 |
Correct |
160 ms |
24056 KB |
Output is correct |
56 |
Correct |
252 ms |
24056 KB |
Output is correct |
57 |
Correct |
79 ms |
14284 KB |
Output is correct |
58 |
Correct |
1 ms |
212 KB |
Output is correct |
59 |
Correct |
0 ms |
212 KB |
Output is correct |
60 |
Correct |
0 ms |
212 KB |
Output is correct |
61 |
Correct |
59 ms |
5716 KB |
Output is correct |
62 |
Correct |
173 ms |
21996 KB |
Output is correct |
63 |
Correct |
171 ms |
22148 KB |
Output is correct |
64 |
Correct |
188 ms |
22032 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Correct |
47 ms |
5796 KB |
Output is correct |
67 |
Correct |
161 ms |
22092 KB |
Output is correct |
68 |
Correct |
176 ms |
22084 KB |
Output is correct |
69 |
Correct |
188 ms |
22032 KB |
Output is correct |
70 |
Correct |
1 ms |
212 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
1 ms |
212 KB |
Output is correct |
73 |
Correct |
45 ms |
5776 KB |
Output is correct |
74 |
Correct |
165 ms |
22108 KB |
Output is correct |
75 |
Correct |
169 ms |
22024 KB |
Output is correct |
76 |
Correct |
155 ms |
22032 KB |
Output is correct |
77 |
Correct |
157 ms |
22120 KB |
Output is correct |
78 |
Correct |
1 ms |
212 KB |
Output is correct |
79 |
Correct |
1 ms |
308 KB |
Output is correct |
80 |
Correct |
4 ms |
596 KB |
Output is correct |
81 |
Correct |
74 ms |
10100 KB |
Output is correct |
82 |
Correct |
1 ms |
256 KB |
Output is correct |
83 |
Correct |
1 ms |
212 KB |
Output is correct |
84 |
Correct |
1 ms |
212 KB |
Output is correct |
85 |
Correct |
40 ms |
6268 KB |
Output is correct |
86 |
Correct |
78 ms |
10100 KB |
Output is correct |
87 |
Correct |
89 ms |
10100 KB |
Output is correct |
88 |
Correct |
82 ms |
10060 KB |
Output is correct |
89 |
Correct |
82 ms |
14196 KB |
Output is correct |
90 |
Correct |
1 ms |
340 KB |
Output is correct |
91 |
Correct |
1 ms |
212 KB |
Output is correct |
92 |
Correct |
6 ms |
596 KB |
Output is correct |
93 |
Correct |
73 ms |
10104 KB |
Output is correct |
94 |
Incorrect |
1 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
95 |
Halted |
0 ms |
0 KB |
- |