# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298392 | Abelyan | Rectangles (IOI19_rect) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//#pragma GCC target("avx2")
//#pragma GCC optimization("unroll-loops")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
using namespace std;
vector<int> ans,g[1000006];
int a,b;
bool col[1000006];
void dfsb(int v){
col[v]=true;
ans[v]=2;
b--;
if (!b)return;
trav(to,g[v]){
if (col[to])continue;
dfs(to);
if (!b)return;
}
}
void dfsa(int v){
col[v]=true;
ans[v]=1;
a--;
if (!a)return;
trav(to,g[v]){
if (col[to])continue;
dfs(to);
if (!a)return;
}
}
vector<int> find_split(int n, int A, int B, int C, vector<int> p, vector<int> q) {
fill(all(ans),3);
a=A;
b=B;
FOR(i,p.size()){
g[p[i]].ad(g[q[i]]);
g[q[i]].ad(g[p[i]]);
}
dfsb(0);
FOR(i,n){
if (!col[i]){
dfsa(i);
break;
}
}
return ans;
}