# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
263538 | T0p_ | Experimental Charges (NOI19_charges) | C++14 | 50 ms | 3072 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<bits/stdc++.h>
using namespace std;
int pa[200200];
int fp(int node)
{
return (node == pa[node]) ? node : pa[node] = fp(pa[node]);
}
int main()
{
int n, q;
scanf(" %d %d",&n,&q);
for(int i=1 ; i<=n+n ; i++)
pa[i] = i;
while(q--)
{
char c;
int a, b;
scanf(" %c %d %d",&c,&a,&b);
if(c == 'A')
{
pa[fp(a)] = fp(b+n);
pa[fp(a+n)] = fp(b);
}
else if(c == 'R')
{
pa[fp(a)] = fp(b);
pa[fp(a+n)] = fp(b+n);
}
else
{
if(fp(a) == fp(b+n)) printf("A\n");
else if(fp(a) == fp(b)) printf("R\n");
else printf("?\n");
}
}
return 0;
}
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... |