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