fork download
  1.  
  2. #include<bits/stdc++.h>
  3. // #pragma GCC optimize("Ofast")
  4. // #pragma GCC target("avx,avx2,fma")
  5. // #pragma GCC optimization("unroll-loops")
  6. // #pragma GCC optimize("unroll-loops")
  7. // #pragma GCC optimize("fast-math")
  8. // #pragma GCC optimize("no-stack-protector")
  9. // #define ll __int128
  10. #define ll long long
  11. // #define ll int
  12. #define f(i,a,b) for(int i=a;i<b;i++)
  13. // #define mod 1000000007
  14. #define mod 998244353
  15. #define mp make_pair
  16. #define uniq(v) (v).erase(unique(all(v)),(v).end())
  17. #define ff first
  18. #define ss second
  19. #define rf(i,a,b) for(int i=a;i>=b;i--)
  20. #define sc(a) scanf("%lld",&a)
  21. #define pf printf
  22. #define sz(a) (int)(a.size())
  23. #define psf push_front
  24. #define ppf pop_front
  25. #define ppb pop_back
  26. #define pb push_back
  27. #define pq priority_queue
  28. #define all(s) s.begin(),s.end()
  29. #define sp(a) setprecision(a)
  30. #define rz resize
  31. #define ld long double
  32. #define inf (ll)1e18
  33. #define ub upper_bound
  34. #define lb lower_bound
  35. #define bs binary_search
  36. #define eb emplace_back
  37. const double pi = acos(-1);
  38. // ll binpow(ll a, ll b){ll res=1;while(b!=0){if(b&1)res*=a;a*=a;b>>=1;}return res;}
  39. ll binpow(ll a, ll b, ll md){ll res=1;a%=mod;while(b!=0){if(b&1)res*=a,res%=md;a*=a,a%=md;b>>=1;}return res%md;}
  40.  
  41. using namespace std;
  42.  
  43. const int N=(1<<22);
  44.  
  45. int main()
  46. {
  47. ios_base::sync_with_stdio(false);
  48. cin.tie(NULL);
  49. freopen("xortransform.in","r",stdin);
  50. freopen("xortransform.out","w",stdout);
  51. // #ifndef ONLINE_JUDGE
  52. // freopen("input.txt","r",stdin);
  53. // freopen("output.txt","w",stdout);
  54. // #endif
  55. int z=1;
  56. // cin>>z;
  57. f(i,1,z+1)
  58. {
  59. int n,m,q;
  60. cin>>n>>m>>q;
  61. int dp[N]={},a[n][m];
  62. f(i,0,n)
  63. {
  64. f(j,0,m)
  65. {
  66. cin>>a[i][j];
  67. dp[i|j]^=a[i][j];
  68. }
  69. }
  70. f(i,0,22)
  71. {
  72. for(int mask=0;mask<N;mask++)
  73. {
  74. if(mask&(1<<i))
  75. dp[mask]^=dp[mask^(1<<i)];
  76. }
  77. }
  78. int prev=0;
  79. while(q--)
  80. {
  81. int k;
  82. cin>>k;
  83. k^=prev,k&=N-1;
  84. prev=dp[k];
  85. cout<<prev<<"\n";
  86. }
  87. }
  88. }
Success #stdin #stdout 0.07s 20312KB
stdin
4 5 3
9 8 1 3 6
1 2 5 2 5
3 4 3 7 7
7 8 3 5 1
3
31
108
stdout
Standard output is empty