# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096325 | vjudge1 | Inside information (BOI21_servers) | C++14 | 642 ms | 524288 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<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define reg register
using namespace std;
const int N=300000;
int n,m,s,l,k,cnt[N];
vector<int>num[N];
vector<int>a;
int main()
{
scanf("%d%d",&n,&k);
k+=n-1;
for(reg int i=1;i<=n;i++)
{
num[i].push_back(i);
cnt[i]=1;
}
for(;k;k--)
{
char op=getchar();
while(op!='S'&&op!='Q'&&op!='C')
op=getchar();
if(op=='S')
{
int x,y;
scanf("%d%d",&x,&y);
a=num[y];
for(auto z:num[x])
{
num[y].push_back(z);
++cnt[z];
}
for(auto z:a)
{
num[x].push_back(z);
++cnt[z];
}
}
if(op=='Q')
{
int x,y;
scanf("%d%d",&x,&y);
bool flag=0;
for(auto z:num[x])
if(z==y)
{
flag=1;
break;
}
if(flag)
puts("yes");
else
puts("no");
}
if(op=='C')
{
int x;
scanf("%d",&x);
printf("%d\n",cnt[x]);
}
}
}
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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |