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
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template <typename num_t> using ordered_set = tree<num_t,null_type,less<num_t>,rb_tree_tag,tree_order_statistics_node_update>; const int DEBUGGER = 0; #define io ios_base::sync_with_stdio(0); cin.tie(NULL) #define mset(a,v) memset(a,v,sizeof(a)) #define lp(i,a,n) for(int i=a;i<n;i++) #define lpr(i,a,n) for(int i=n-1;i>=a;i--) #define stlp(it,stl) for(__typeof(stl.begin()) it=stl.begin();it!=stl.end();it++) #define stlpr(it,stl) for(__typeof(stl.rbegin()) it=stl.rbegin();it!=stl.rend();it++) #define r(a) a.begin(),a.end() #define II ({ ll TEMP; cin>>TEMP; TEMP; }) #define SI ({ string TEMP; cin>>TEMP; TEMP; }) #define AI(a) ({ int n=sizeof(a)/sizeof(a[0]); lp(I,0,n)a[I]=II; }) #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'; }) #define VI(v) ({ lp(I,0,v.size())v[I]=II; }) #define VO(v) ({ lp(I,0,v.size()){cout<<(I?" ":"")<<v[I];} if(DEBUGGER)cout<<endl;else cout<<'\n'; }) #define outa(a) ({ if(DEBUGGER)dbg(a); else cout<<a<<'\n'; }) #define dbg(a) ({ if(DEBUGGER)cout<<#a<<" = "<<a<<endl; }) #define cbit(n,p) ((n)&(1LL<<(p))) #define sbit(n,p) ((n)|(1LL<<(p))) #define tbit(n,p) ((n)^(1LL<<(p))) #define F first #define S second typedef long long ll; typedef pair<ll,ll> pll; typedef vector<ll> vl; const ll MAX = 5e5+5; const ll MAX2= 1e6+6; const ll MOD = 1e9+7; const ll INF = 9e18; const double PI = 3.141592653589793238462; ll addM(ll a,ll b){return (a+=b)>=MOD?(a-=MOD):a;} ll subM(ll a,ll b){return (a-=b)<0?(a+=MOD):a;} ll n,a[MAX],ans; void range(int c){ ll l[n], r[n]; stack<ll>st; st.push(-1); lp(i,0,n){ if(!c)while(!st.empty() && st.top()!=-1 && a[i]>a[st.top()])st.pop(); else while(!st.empty() && st.top()!=-1 && a[i]<a[st.top()])st.pop(); l[i]=st.top()+1; st.push(i); } while(!st.empty())st.pop(); st.push(n); lpr(i,0,n){ if(!c)while(!st.empty() && st.top()!=n && a[i]>=a[st.top()])st.pop(); else while(!st.empty() && st.top()!=n && a[i]<=a[st.top()])st.pop(); r[i]=st.top()+1; st.push(i); } lp(i,0,n){ ll rg=(i-l[i]+1)*(r[i]-i+1); if(rg&1) ans^=a[i]; } } void solve(){ n=II; lp(i,0,n)a[i]=II; range(0); range(1); outa(ans); } int main(void){ io; int multipletest=0; if(multipletest){ int tc; cin>>tc; while(tc--) solve(); } else solve(); return 0; }