제출 #1271563

#제출 시각아이디문제언어결과실행 시간메모리
1271563ashishlimitlessXOR (IZhO12_xor)C++20
100 / 100
125 ms56624 KiB
#include <bits/stdc++.h> // #include "atcoder/convolution.hpp" // #include "atcoder/dsu.hpp" // #include "atcoder/fenwicktree.hpp" // #include "atcoder/lazysegtree.hpp" // #include "atcoder/math.hpp" // #include "atcoder/maxflow.hpp" // #include "atcoder/mincostflow.hpp" // #include "atcoder/modint.hpp" // #include "atcoder/scc.hpp" // #include "atcoder/segtree.hpp" // #include "atcoder/string.hpp" // #include "atcoder/twosat.hpp" using namespace std; //using namespace atcoder; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define ll long long #define pb push_back #define F first #define S second #define I insert #define ull unsigned long long typedef long double lld; #define PI 3.141592653589793238462 #define set_bits __builtin_popcountll #define mem(x,v) memset(x,v,sizeof(x)) #define inp(v,n) loo(i,n){cin>>v[i];} void _print(ll t) {cerr << t;} void _print(int t) {cerr << t;} void _print(string t) {cerr << t;} void _print(char t) {cerr << t;} void _print(lld t) {cerr << t;} void _print(double t) {cerr << t;} void _print(ull t) {cerr << t;} template <class T, class V> void _print(pair <T, V> p); template <class T> void _print(vector <T> v); template <class T> void _print(set <T> v); template <class T, class V> void _print(map <T, V> v); template <class T> void _print(multiset <T> v); template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.F); cerr << ","; _print(p.S); cerr << "}";cerr<<"\n";} template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";cerr<<"\n";} template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";cerr<<"\n";} template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";cerr<<"\n";} template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {cerr<<"{"<<i.F<<" "<<i.S<<"} ";} cerr << "]";cerr<<"\n";} #define vll vector<ll> #define vdd vector<double> #define vss vector<string> #define vpl vector<pair<ll,ll>> #define vcl vector<char> #define vvl vector<vector<ll>> #define vvc vector<vector<char>> #define ppi pair<ll,ll> #define maxe(v) *max_element((v).begin(),(v).end()); #define mine(v) *min_element((v).begin(),(v).end()); #define loo(i,n) for(long long i=0;i<n;i++) #define sor(v) sort(v.begin(),v.end()); #define pyes cout<<"YES\n"; #define pno cout<<"NO\n"; #define ayes cout<<"Yes\n"; #define ano cout<<"No\n"; #define mll map<ll,ll> #define mcl map<char,ll> #define mod 1000000007 #define ft front() #define bk back() #define pf push_front #define bg(x) begin(x) #define all(x) bg(x), end(x) #define rall(x) x.rbegin(), x.rend() #define lb lower_bound #define ub upper_bound #define each(a,x) for(auto a:x) #define nl cout<<"\n"; #define pri(xx) cout<<xx<<"\n"; #define sll set<ll> #define sch set<char> #define rt return #define sz(x) x.size() #define pq priority_queue #define pql priority_queue<ll> #define INF 1e9 #define manh(a,b,c,d) abs(a-c)+abs(b-d) #define euc(a,b,c,d) sqrt((a-c)*(a-c)+(b-d)*(b-d)) #define foo(i,a,b) for(ll i=a;i<b;i++) #define pril(i,a,b,v) foo(i,a,b){cout<<v[i]<<" ";} #define pqc priority_queue<char> #define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper); #define lowercase(s) transform(s.begin(), s.end(), s.begin(), ::tolower); class Trie{ public: Trie* child[2]; int mi; Trie(){ child[0]=child[1]=NULL; mi=INT_MAX; } }; Trie* root; void insert(int x,int ind){ Trie* cur=root; for(int i=29;i>=0;i--){ int b=(x>>i)&1; if(cur->child[b]==NULL){ cur->child[b]=new Trie(); } cur=cur->child[b]; cur->mi=min(ind,cur->mi); } } int query(int x,int k){ Trie* cur=root; int ans=INT_MAX; for(int i=29;i>=0;i--){ if(!cur) break; int kbit=(k>>i)&1; int xbit=(x>>i)&1; if(!kbit){ if(cur->child[xbit^1]) ans=min(ans,cur->child[xbit^1]->mi); cur=cur->child[xbit]; } else{ cur=cur->child[xbit^1]; } } if(cur) ans=min(ans,cur->mi); return ans; } void madara(){ int n,k; cin>>n>>k; int pre=0; insert(pre,0); int ans=0,st=-1; for(int i=1;i<=n;i++){ int x; cin>>x; pre^=x; int idx=query(pre,k); if(idx!=INT_MAX){ if(i-idx>ans){ ans=i-idx; st=idx; } else if(i-idx==ans){ st=min(st,idx); } } insert(pre,i); } cout<<st+1<<" "<<ans<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll ashish; ashish=1; while(ashish--){ root=new Trie(); madara(); } return 0; } /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++*%*+++++++++++++++++#++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++*%%#*+++++++#*+++++#%*+++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++*%%%%%#+++++*%#+++*%%#+++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++*%%%%%%%*+++%%%*+%%%%*++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++#%%%%%%%%%**%%%#%%%%#+++++++++++*#%%#++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++*************#%%%%%%%%%%%%%%%%%%#++++**##%%%%%*+++*#*++++++++++++++++++++ +++++++++++++++++++++++++**#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#**#%%%%*+++++++++++++++++++++ +++++++++++++++++++++++++***#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%%%%%%%%%*++++++++++++++++++++++ ++++++++++++++++++++++++++++++++*#%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*+++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++*%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*+++++++++++++++++++++++++ +++++++++++++++++++++++++++++++*#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*++++++++++++++++++++++++++ ++++++++++++++++++++++++++++#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#*++++++++++++++++++++++ ++++++++++++++++++++++++*#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###*++++++++++++++ +++++++++++++++++++++*#%%%%@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#****+++++++++++++++++++ ++++++++++++++++++*#%%%%##*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*#%%%%%%%%%%%%%%%%#+++++++++++++++++++++ ++++++++++++++++*%#**+++#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*-=@%%%%%%%%%%%%%%%%%*+++++++++++++++++++ +++++++++++++++++++++*#%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*---*@%%%%%%%%%%%%%%%%%#++++++++++++++++++ +++++++++++++++++++*%%%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#----=@@%%%%%%%%%%%%%%%%%%#++++++++++++++++ +++++++++++++++++#%%%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%@%%%%%%%%%%#-----++@@%%%%%%%%%%%%%%%%%%%*++++++++++++++ ++++++++++++++*#%%%%@@%#%%%%%%%%%%%%%%%%@%%%%%%%@@%%%%%%%%%%#=----+--%@%%%%%%%%%%%%%%%%%%%%%*++++++++++++ ++++++++++++#%%%%%#**+#%%%%%%%%%%%%%%%@@%%%%%%@@@%%%%%%%@%%@=-=****+=*@@%%%%%%%%%%%%%%%%%%%%%#+++++++++++ +++++++++*%%%%#*+++++#%%%%%%%%%%%%%%@@@%%%%%@@@@%%%%@%%%%%%==#+%@@@*=+@@@%%%%%%%%%%%%%%%%%%%%%%#+++++++++ ++++++++++++++++++++%%%%%%%%%%%%%%@@@%%%%%@@@@@@%%%@%%#+%%+--#=-=+#*=-#@@@%%%%%%%%%%%%%%%%%%@%%%%#++=++++ ++++++++++++++++++*%%%%%%%%%%%%%@@@@%%%%@@@@@@@%%%@@%%+#%*---+=-=+++==+@@@@%%%%%%%%%%%%%%%%%%%@%%%%%*+=== +++++++++++++++++*%%%%%%%%%%%%@@@@@%%%@@@@@@@@%%%@@%%==%*----+=-------+@@@@@%%%%%%%%%%%%%%%%%%%%#*#%%%#*+ ++++++++++++++++*%%%%%%%%%%%%@@@@@%%@@@@@@@@@%%%@@%%+-=%-=+==#-+-----=#@@@@@@%%%%%%%%%%%%%%%%%%%%%#+++*#% +++++++++++++++*%%%%%@%%%%%@@@@@@%@@@@@@%%%%%%%@@@%+--=----==---=----=%@@@@@@%%%%%%%%%%%%%%%%%%%%%%%*++++ ++++++++++++++*%%%%@%%%%%%@@@@@@@@@%########%@@@@%*--------------+---+@@@@@@@@%%%%@@%%%%%%%%%%%%%%%%%%+== ++++++++++++++%%%@%#%%%%@@@@@@@@%###########%@@@%#----====++==---+--=%@@@@@@@@@%%%%@%%%%%%%%%%%%%%%%%%%#= +++++++++++++%%%@#*%%%%@@@@@@@##############%@@@#----=--------*--+--#@@@@@@@@@@@%%%@@%%%%%%%%%%%%%%%%%%%% ++++++++++++#%%%**%%%@@@@@@@################@@@%+=------===+-----==#@@@@@@@@@@@@@%%%@@%%%%%%%%%%%%%%%%%%% +++++++++++*%%#++%%%@@@@@@%#################%%@+===--------------+%@@@@@@@@@@@@@@@%%@@@%%%%%%%%%%%%%%%%%% ++++++++++*%%*++#%%@@@@@@%##################*%#*=====-----------+@@@@@@@@@###@@@@@@%%@@@%%%%%%%%%%%%%%%%% ++++++++++##++++%%@@@@@@@%#########%%######%+#==**=====--------*@@@@@@@@@@####@@@@@@%@@@@%%%%%%%%%%%%%%%% +++++++++++++++*%@@@@@@@@##################%======*+======---=*@@@@@@@@@%%####@@@@@@@%@@@@%%%%%%%%%%%%%%% +++++++++++++++%@@@@@@@@@###################========+********+*@@@@@%%%%%%####@@@@@@@@@@@@@@%%%%%%%%%%%%% ++++++++++++*#%%#####%%@@%#################%#%%%%%%%%%%%%#*+==#%%%%%%%%%%%####@@@@@@@@@@@@@@@%%%%%@%%%%%% ++++++++*#%##################%%%##########%%%%%%%%%%%%%%%%%%%%@%%%%%%%%%%####%@@@@@@@@@@@@@@@@@%%%%@%%%%% +++++*############################%%%#####%%%%%%%%%%%%%%%%%%%%%@%%%%%%%%%####@@@@@@@@@@@@@@@@@@@%%%%@@%%% ++*##############################%%%%%%%%####%%%%%%%%%%%%%%%%%%@%%%%%%%%%####@@@@@@@@@@@@@@@@@@@@@%%%@@@% *#############################%%%@%%%@%*########%%%%%%%%%%%%%%%@%%%%%%%%#####@@@@@@@@@@@@@@@@@@@@@@%%@@@@ %%%%%%%%%%%%%#*%%%%%%#######%%%@%%%@%###*##########%%%%%%%%%%%%@%%%%%%%%#####@@@@@@@@@@@@@@@@@@@@@@@@%@@@ ###########*+######%%%%%%%%%%%%%@%#######*############%%%%%%%%%@%%%%%%%%######%%%@@@@@@@@@@@@@@@@@@@@@@@@ ##########+###########%%%%%%%%%%#########%*#############%%%%%%%@%%%%%%%@####%%######%@@@@@@@@@@@@@@@@@@@@ ########%%##########%%%%%%%%@%#############+##############%%%%%%%%###*#%%@%#############%@@@@@@@@@@@@@@@@ ##################%%@%@%%%%%#%##############+########################+*%%%%%%%############%@@@@@@@@@@@@@@ ################%%@%%@%%%%####%#######%%%%%%%%%%%%%%%%%%%%%%#########++%#%%%%%%%#############%@@@@@@@@@@@ ##############%%%@%@%%%%######%%#####%##########################%%%%%*+%###%%%%%#%%############@@@@@@@@@@ ###########%%%%@%%%%#########%%###%%%##################################%%%%##%%%%%##%##########%%@@@@@@@@ %%%%%%%%%%%%%%%%%%######%%##%%%%%%##%%######################################%%%%%%%%%##%#######%*%####%@@ %%%%%%%%%%%%%%%%%#####%%%@@%%%%###%%#%%####%%%%%#%############################%%##%%%%%#######%##*######% %%###%%%%%%%%@%%#####%%#########%%#%%##%########*%########%%%@%%%######%#%#####%###%%%%%@####%########### #######%%%%%%%%%#######%%%@@@%%%##%%#%%%%%%%%%%######################%%%%%######%###%%%%%%@%#%%%#%####### ####%##%%%@%%%%%%%%###%%%%%%%%%%%%%############%%########################%###%%%%%###%%%%%%%%@%%%######## ##%%#%%%@%%%%%%%%%%%%%%%##########################@%%%%#%%%###########%%%########%####%%%@%%%%%%%%%#%#### #%%%%%%%%%%%%%%%%%%##########################################--------=+*####%#####%###%%%%%%%%%%%%%%##%## %%%%%%%%%%%%%%%###############################################+-----------+%%%%####%%##%%%%%%%%%%%%%%%### %%@%%%%%%%%%###################################################*-----------+%%%%####%%#%%%%%%%%%%%%%%%@%# %%%%%%%%%%#####################################################%+---========%%%%%#####%%%%%%%%%%%%%%%%%@% @%%%%%%%%#####################################################%%+===*#*+====#%%%%%%#%%%%%%%%%%%%%%%%%%%%% %%%%%%%#############################################%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%#####%@%%%%%######%%@ %%%%%#############################################%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%############# %%%%%###########################################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%############## %%%%%%#########################################%%%%%%%%%@%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%############### %%%%%%########################################%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%############## %%%%%%%#####################################%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%############ %%%%%%%###################################%%%%%%%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%########### %%%%%%%%################################%%%%%%%%@@%%%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%######### %%%%%%%%##############################%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%####### %%%%%%%%%##########################%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###### #%%%%%%%%%######################%%%%@%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##### +%%%%%%%%%%##################%%%@@%%%%%%%%@%%%%%%%%%%%%@%%%%%%%%%%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#### +*%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%### +++%%%%%%%%%%%%%%%%%%%@@%%%%%%%@%%%%%%%%%%%%%@%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%### ++++*%%%%%%%%%%%%%@%%%%%%%%%%%@%%%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%### ++++++*#%@%%@%%%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%@%%%%%#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%## ++++++++*%%%%%%%%%%%%%%%%%@%%%%%%%%%%%%%%%%%%%#%#%######################%%%%%%%%%%%%%%%%%%@@%%%%%%%%%%### ++++++++*%%%%%%%%%%%%%@@%%%%%%%%%%%%%%%%%%#####%%#############################%%%%%%%%%%%%%%%%%%@%%%##### ++++++++*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%########%%#################################%%%%%%%%%%%%%%%%%%%%%%% +++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%#########%%%%%%%%%%%%%%%##########################%%%%%%%%%%%%%%%%%%% +++++++++#%%%%%%%%%%%%%%%%%%%%%%####%%%%%######%%################%%%%%%##################%%%%%%%%%@%%%%%% +++++++++*%%%%%%%%%%%%%%%%%%%%%%%###############%########################%%%%############%%%%%%%%%@%%%%%% ++++++++++%%%%%%%%%%%%%%%%%%#####################%############################%%%%#############%%%@%%%%%% +++++++++#############%%##########################%################################%%%###########%%%##%%% +++++++++##########%%############################%#####################################%%#########%#+++++ ++++++++*#######%%##############################%#######*%################################%%########+++++ ++++++++*#####%%#############%%%%%###%%%%##############%+#%%%%%%%%###########################%%####%+++++ ++++++++####%########*#%%%##########@%%%#################*############%%%%#####################%%##%+++++ ++++++++##%########%#*%###########%#@%%%%####################################%%%#################%%%*++++ ++++++++%%######%%##*############%%@@%%%%##########################################%%#%############%*++++ +++++++######%%####*+###########%#@%%@%%%%##########%###################################%############++++ +++++++####%##################%%#%%%%@%@%%##########%#%#################################%##%#########++++ ++++++*##%###################%%%%%%%%%@%%%%##########%%%%%%%%%%%##############################%%#####++++ ++++++*%######################%%%%%%%%%%%%%##%%%%%%%%%%%%%%##@%@%%%%%%%%%%%%####################%%##%#*++ +++++*#####################%%@%%%%%%%%%%%%%%%%%%%%%%#######%*%#################%%%%###############%#%%%%# ++++%#######%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%@@%%#########################################%%###%####%%%%%%% ++*%%%%%%#*%%%%%%%%%%%%%%%%@%%%%##%%%%%%@%@%%%%##############################################*%%###%@@%%% +#%%%%%%#*%#########%%@%%%%%%%%####%%%%%%%@%%%%%#################################################%%%%%%%% ########*###########%%%@%@%%%%######%%%%%@@%%%%%####################################################%%%%% ##################%@%%@@%%%%%#######%%%%%%%@%%%%%##################%###################################%% #################%@%%%%%%%%%%########%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%*%%%%%%%%###########################% ###############%%@%%@%%%%%%%#########%%%%%%%%%%%%%%%%%%%%%%%########*#################%%%%%%%%%%%##%%%### ##############%%%%%%%%%%%%%###########%%%%%%%@%%%%@%%%%#############################################**%%% */
#Verdict Execution timeMemoryGrader output
Fetching results...