#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define vll vector<ll>
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pll pair<ll, ll>
#define mod 1000000007
#define _set tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update>
#define inf (ll)1e15
#define db(x) cout<<#x<<" : "<<x<<endl;
#define PRESICION(x) cout.setf(ios::fixed,ios::floatfield); cout.precision(x);
using namespace std;
using namespace __gnu_pbds;
ll dx[]={1, -1, 0, 0};
ll dy[]={0, 0, 1, -1};
inline ll sm(ll a, ll b){
return ((a%mod)+(b%mod))%mod;
}
inline ll ml(ll a, ll b){
return ((a%mod)*(b%mod))%mod;
}
inline ll rs(ll a, ll b){
return ((a%mod)-(b%mod)+mod)%mod;
}
ll bpow(ll a , ll b) {
if (b==0)return 1;
if (b%2!=0)return ((bpow(a, b-1)%mod)*(a%mod))%mod;
ll r=bpow (a ,b/ 2) ;
return ((r%mod)*(r%mod))%mod;
}
vector<vector<ll>> adj;
std::vector<int> find_split(int n, int a, int b, int c, std::vector<int> p1, std::vector<int> q){
vector<vector<ll>>().swap(adj);
adj.resize(n+1);
for(int i=0; i<p1.size(); i++){
adj[p1[i]].push_back(q[i]);
adj[q[i]].push_back(p1[i]);
}
ll o=0, p=0;
vector<int>res;
res.assign(n, 0);
for(int i=0; i<a; i++){
res[o]=1;
for(auto y: adj[o]){
if(y!=p){p=o;o=y;break;}
}
}
for(int i=a; i<a+b; i++){
res[o]=2;
for(auto y: adj[o]){
if(y!=p){p=o;o=y;break;}
}
}
for(int i=a+b; i<n; i++){
res[o]=3;
for(auto y: adj[o]){
if(y!=p){p=o;o=y;break;}
}
}
return res;
}/*
int main(){
vector<int> res=find_split(8, 2, 3, 3, {0, 1, 2, 2, 2, 2, 0}, {1, 2, 3, 4, 5, 6, 7});
for(auto y: res)cout<<y<<" ";
cout<<endl;
}*/
# | 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... |