# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291173 | Dremix10 | Split the Attractions (IOI19_split) | C++17 | 120 ms | 15096 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 long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
#define p(x) cerr<<#x<<" = "<<x<<endl;
#define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
#define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
#define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
#define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
#define p(x)
#define p2(x,y)
#define pp(x)
#define pv(x)
#define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;
vector<vector<int> > adj(N);
vector<int> res;
bool v[N];
int siz[3];
int curr,cnt;
void dfs(int s){
cnt++;
if(cnt==siz[curr-1]+1){
curr++;
cnt = 1;
}
v[s] = 1;
res[s] = curr;
for(auto x : adj[s])
if(!v[x])
dfs(x);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
siz[0] = a;
siz[1] = b;
siz[2] = c;
int i;
for(i=0;i<p.size();i++){
int x = p[i],y = q[i];
adj[x].push_back(y);
adj[y].push_back(x);
}
res.assign(n,0);
int start = 0;
for(i=0;i<n;i++)
if(adj[i].size()==1)start = i;
curr = 1;
cnt = 0;
dfs(start);
return res;
}
Compilation message (stderr)
# | 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... |