fork download
  1. #include<bits/stdc++.h>
  2. //#include<boost/multiprecision/cpp_int.hpp>
  3. #define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  4. using namespace std;
  5. //using boost::multiprecision::cpp_int;
  6. typedef unsigned long long ULL;
  7. typedef long double LL;
  8. const int inf=0x3f3f3f3f;
  9. int t,n,m,q;
  10. int32_t main()
  11. {
  12. int cnt=0;
  13. fast;
  14. cin>>t;
  15. if(t>=1&&t<=300)
  16. {
  17. while(t--)
  18. {
  19. cnt=0;
  20. cin>>n>>m>>q;
  21.  
  22. int ro=0;
  23. int re=0;
  24. int co=0;
  25. int ce=0;
  26. int row[n];
  27. int col[m];
  28. for(int i=0;i<n;++i)
  29. row[i]=0;
  30. for(int i=0;i<m;++i)
  31. col[i]=0;
  32.  
  33. while(q--)
  34. {
  35. int v1;
  36. int v2;
  37. cin>>v1>>v2;
  38. v1-=1;
  39. v2-=1;
  40. row[v1]^=1;
  41. col[v2]^=1;
  42. }
  43.  
  44. for(int i=0;i<n;++i)
  45. if(row[i]==1)
  46. ++ro;
  47. else
  48. ++re;
  49.  
  50. for(int i=0;i<m;++i)
  51. if(col[i]==1)
  52. ++co;
  53. else
  54. ++ce;
  55.  
  56. cout<<(ro*ce)+(co*re)<<endl;
  57. }
  58. }
  59. }
Success #stdin #stdout 0s 4272KB
stdin
Standard input is empty
stdout
Standard output is empty