#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;
}
};
int32_t construct(vector<vector<int32_t>> 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]) 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<int32_t>> rval(n,vector<int32_t>(n,0));
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < els2[i].size(); j++){
int x = els2[i][j];
int y = els2[i][(j+1)%els2[i].size()];
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];
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 'int32_t construct(std::vector<std::vector<int> >)':
supertrees.cpp:82:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | for (int j = 0; j < els2[i].size(); j++){
| ~~^~~~~~~~~~~~~~~~
supertrees.cpp:91:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
91 | for (int j = 1; j < els[i].size(); j++){
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
b[0][0] is not 0 |
2 |
Halted |
0 ms |
0 KB |
- |