이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include "bits/stdc++.h"
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) ((ll)(a.size()))
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pi 3.14159265358979323846
#define here cerr<<"=============================================================================\n"
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define ceri2(a,l,r,n,m) {for(ll i = l;i<=r;i++){for(ll j = n;j<=m;j++) cerr<<a[i][j]<< " ";cerr<<endl;}}
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
using namespace std;
#define maxn 1005
ll dsu[maxn];
ll root(ll x){
while(x!=dsu[x]){
dsu[x] = dsu[dsu[x]];
x = dsu[x];
}
return x;
}
void upd(ll x,ll y){dsu[root(x)] = root(y);}
bool get(ll x,ll y){return root(x)==root(y);}
vector<ll> v[maxn];
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
vector<std::vector<int>> answer;
for(ll i = 0;i<n;i++){
vector<int> w(n);
answer.pb(w);
}
iota(dsu,dsu+n,0);
for(ll i = 0;i<n;i++){
for(ll j = 0;j<n;j++){
if(p[i][j]==3) return 0;
}
for(ll j = 0;j<n;j++){
if(p[i][j]==1) upd(i,j);
}
}
vector<vector<ll> >w;
for(ll i = 0;i<n;i++) v[root(i)].pb(i);
for(ll i = 0;i<n;i++) if(sz(v[i])) w.pb(v[i]);
for(ll i = 0;i<sz(w);i++){
for(ll j = 0;j<sz(w[i])-1;j++){
answer[w[i][j]][w[i][j+1]] = 1;
answer[w[i][j+1]][w[i][j]] = 1;
}
if(i<sz(w)-1) answer[w[i].back()][w[i+1].back()] = 1;
if(i<sz(w)-1) answer[w[i+1].back()][w[i].back()] = 1;
}
if(sz(w)>2) answer[w[0].back()][w.back().back()] = 1;
if(sz(w)>2) answer[w.back().back()][w[0].back()] = 1;
build(answer);
return 1;
}
/*
4
1 1 2 2
1 1 2 2
2 2 1 2
2 2 2 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |