# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1242698 | mohamedboukerche55 | Split the Attractions (IOI19_split) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
vector<int> finode_split(int n, int a, int b, int c, vector<int> p, vector<int> q)
{
vector<vector<int>>hello(n);
for(int i = 0 ; i < p.size(); i++)
{
hello[p[i]].push_back(q[i]);
hello[q[i]].push_back(p[i]);
}
vector<int> ans;
int curr = 1;
int no = 0;
int pz = -1;
for(int i = 0 ;i < n ;i++)
{
if(hello[i].size() == 1)
{
no = i;
}
}
for(int i = 0 ; i < n ; i++)
{
if(i == a + b || i == a)
{
curr++;
}
}
ans[n] = curr;
for(auto i : hello[no])
{
if (i != pz)
{
pz = no;
no = i;
break;
}
}
return ans;
}