Submission #209435

#TimeUsernameProblemLanguageResultExecution timeMemory
209435model_codeExperimental Charges (NOI19_charges)C++17
100 / 100
47 ms1660 KiB
#include <bits/stdc++.h> using namespace std; pair<int,bool> p[100009]; pair<int,bool> fp(int x){ if(p[x].first==x)return make_pair(x, 0); pair<int,bool> xpar = fp(p[x].first); return p[x] = make_pair(xpar.first, xpar.second^p[x].second); } void mg(int x,int y,bool r){ pair<int,bool> xpar = fp(x), ypar = fp(y); if (xpar.first == ypar.first) return; p[xpar.first]= make_pair(ypar.first, r^xpar.second^ypar.second); } int main(){ int n,q; scanf("%d%d",&n,&q); for (int i = 0; i < n; i++) p[i] = make_pair(i, 0); for (int i = 0; i < q; i++) { char t; int a,b; scanf(" %c%d%d",&t,&a,&b);a--;b--; if (t=='Q') { pair<int,bool> apar = fp(a), bpar = fp(b); if (apar.first !=bpar.first) puts("?"); else { puts((apar.second != bpar.second)?"A":"R"); } } else mg(a,b,t=='A'); } }

Compilation message (stderr)

charges.cpp: In function 'int main()':
charges.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&q);
  ~~~~~^~~~~~~~~~~~~~
charges.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d%d",&t,&a,&b);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...