Submission #263538

#TimeUsernameProblemLanguageResultExecution timeMemory
263538T0p_Experimental Charges (NOI19_charges)C++14
100 / 100
50 ms3072 KiB
#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)

charges.cpp: In function 'int main()':
charges.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf(" %d %d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~
charges.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf(" %c %d %d",&c,&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...