Loading...
Submission
# When Author Problem Language CPU Memory
4990 2022-04-15 20:44:05 ewu_ieee21_user_34 Find MinMaxXoR Number C++ 17 385 ms 19228 kb Accepted
Test Cases
# CPU Memory Points
1 3 ms 3468 kb 1 Accepted
2 2 ms 3332 kb 1 Accepted
3 3 ms 3324 kb 1 Accepted
4 2 ms 3328 kb 1 Accepted
5 3 ms 3416 kb 1 Accepted
6 3 ms 3516 kb 1 Accepted
7 10 ms 3812 kb 1 Accepted
8 10 ms 3724 kb 1 Accepted
9 79 ms 5744 kb 1 Accepted
10 385 ms 15136 kb 1 Accepted
11 385 ms 15184 kb 1 Accepted
12 300 ms 19228 kb 1 Accepted
13 383 ms 15044 kb 1 Accepted
14 375 ms 15352 kb 1 Accepted
15 383 ms 15248 kb 1 Accepted
16 361 ms 16156 kb 1 Accepted
Source Code
  1. #include<bits/stdc++.h>
  2. #include<ext/pb_ds/assoc_container.hpp>
  3. #include<ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6.  
  7. template <typename num_t>
  8. using ordered_set = tree<num_t,null_type,less<num_t>,rb_tree_tag,tree_order_statistics_node_update>;
  9.  
  10. const int DEBUGGER = 0;
  11.  
  12. #define io ios_base::sync_with_stdio(0); cin.tie(NULL)
  13. #define mset(a,v) memset(a,v,sizeof(a))
  14. #define lp(i,a,n) for(int i=a;i<n;i++)
  15. #define lpr(i,a,n) for(int i=n-1;i>=a;i--)
  16. #define stlp(it,stl) for(__typeof(stl.begin()) it=stl.begin();it!=stl.end();it++)
  17. #define stlpr(it,stl) for(__typeof(stl.rbegin()) it=stl.rbegin();it!=stl.rend();it++)
  18. #define r(a) a.begin(),a.end()
  19. #define II ({ ll TEMP; cin>>TEMP; TEMP; })
  20. #define SI ({ string TEMP; cin>>TEMP; TEMP; })
  21. #define AI(a) ({ int n=sizeof(a)/sizeof(a[0]); lp(I,0,n)a[I]=II; })
  22. #define AO(a) ({ int n=sizeof(a)/sizeof(a[0]); lp(I,0,n){cout<<(I?" ":"")<<a[I];} if(DEBUGGER)cout<<endl;else cout<<'\n'; })
  23. #define VI(v) ({ lp(I,0,v.size())v[I]=II; })
  24. #define VO(v) ({ lp(I,0,v.size()){cout<<(I?" ":"")<<v[I];} if(DEBUGGER)cout<<endl;else cout<<'\n'; })
  25. #define outa(a) ({ if(DEBUGGER)dbg(a); else cout<<a<<'\n'; })
  26. #define dbg(a) ({ if(DEBUGGER)cout<<#a<<" = "<<a<<endl; })
  27. #define cbit(n,p) ((n)&(1LL<<(p)))
  28. #define sbit(n,p) ((n)|(1LL<<(p)))
  29. #define tbit(n,p) ((n)^(1LL<<(p)))
  30. #define F first
  31. #define S second
  32.  
  33. typedef long long ll;
  34. typedef pair<ll,ll> pll;
  35. typedef vector<ll> vl;
  36.  
  37. const ll MAX = 5e5+5;
  38. const ll MAX2= 1e6+6;
  39. const ll MOD = 1e9+7;
  40. const ll INF = 9e18;
  41. const double PI = 3.141592653589793238462;
  42. ll addM(ll a,ll b){return (a+=b)>=MOD?(a-=MOD):a;}
  43. ll subM(ll a,ll b){return (a-=b)<0?(a+=MOD):a;}
  44.  
  45. ll n,a[MAX],ans;
  46.  
  47. void range(int c){
  48. ll l[n], r[n];
  49. stack<ll>st;
  50. st.push(-1);
  51. lp(i,0,n){
  52. if(!c)while(!st.empty() && st.top()!=-1 && a[i]>a[st.top()])st.pop();
  53. else while(!st.empty() && st.top()!=-1 && a[i]<a[st.top()])st.pop();
  54. l[i]=st.top()+1;
  55. st.push(i);
  56. }
  57. while(!st.empty())st.pop();
  58. st.push(n);
  59. lpr(i,0,n){
  60. if(!c)while(!st.empty() && st.top()!=n && a[i]>=a[st.top()])st.pop();
  61. else while(!st.empty() && st.top()!=n && a[i]<=a[st.top()])st.pop();
  62. r[i]=st.top()+1;
  63. st.push(i);
  64. }
  65. lp(i,0,n){
  66. ll rg=(i-l[i]+1)*(r[i]-i+1);
  67. if(rg&1)
  68. ans^=a[i];
  69. }
  70. }
  71.  
  72. void solve(){
  73. n=II;
  74. lp(i,0,n)a[i]=II;
  75. range(0);
  76. range(1);
  77. outa(ans);
  78. }
  79.  
  80. int main(void){
  81. io;
  82. int multipletest=0;
  83. if(multipletest){
  84. int tc;
  85. cin>>tc;
  86. while(tc--)
  87. solve();
  88. }
  89. else
  90. solve();
  91. return 0;
  92. }
  93.