이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define forn(j, i, n) for(int i = j; i <= n; ++i)
#define FOR(j, i, n) for(int i = j; i < n; ++i)
#define nfor(j, i, n) for(int i = n; i >= j; --i)
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
#define pii pair <int, int>
const int maxn=2e5+10;
int n, m, a, b, c, col[maxn], ok, used[maxn];
vector <int> edge[maxn];
void dfs(int v)
{
used[v] = 1;
if(b)
{
col[v] = 2;
b--;
}
else
if(a)
{
col[v] = 1;
a--;
}
for(auto to : edge[v])
{
if(used[to]) continue;
dfs(to);
}
}
vector<int> find_split(int N, int A, int B, int C, vector<int> p, vector<int> q)
{
n = N;
m = q.size();
forn(1, i, n) edge[i].clear();
ok = 0;
FOR(0, i, m)
{
q[i]++;
p[i]++;
edge[q[i]].pb(p[i]);
edge[p[i]].pb(q[i]);
}
vector <pii> sor;
sor.pb({A, 1});
sor.pb({B, 2});
sor.pb({C, 3});
sort(all(sor));
a = sor[0].f;
b = sor[1].f;
c = sor[2].f;
dfs(1);
forn(1, i, n)
{
if(col[i]) continue;
if(a)
{
a--;
col[i] = 1;
}
else
if(c)
{
c--;
col[i] = 3;
}
}
vector <int> res(n, 0);
forn(1, i, n)
{
if(col[i] == 0) col[i] = 3;
res[i-1] = sor[col[i]-1].s;
}
return res;
}
# | 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... |