Created
October 24, 2012 12:30
-
-
Save prongs/3945818 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string.h> | |
#include <algorithm> | |
#include <vector> | |
#include <set> | |
#include <map> | |
/*more #includes. Don't write "using namespace std" here*/ | |
#ifdef __WIN32__ | |
#define getchar_unlocked getchar | |
#endif | |
//Input-output macros | |
#define s(n) scan(&n) | |
#define p(n) printf("%d\n",n) | |
#define pl(n) printf("%lld\n",n) | |
#define sf(n) scanf("%f",&n) | |
#define pf(n) printf("%f\n",n) | |
#define sc(n) scanf("%c",&n); | |
#define pc(n) printf("%c\n",n) | |
#define ss(n) scanf("%s",n) | |
#define ps(n) printf("%s\n",n) | |
// Useful constants | |
#define INF (int)1e9 | |
#define EPS 1e-9 | |
// Useful hardware instructions | |
#define bitcount __builtin_popcount | |
#define gcd __gcd | |
// Useful container manipulation / traversal macros | |
#define forall(i,a,b) for(int i=a;i<b;i++) | |
#define foreach(v,c) for(typeof((c).begin()) v=(c).begin();v!=(c).end();++v) | |
#define all(a) a.begin(),a.end() | |
#define in(a,b) ((b).find(a)!=(b).end()) | |
#define pb push_back | |
#define fill(a,v) memset(a,v,sizeof a) | |
#define sz(a) ((int)(a.size())) | |
#define mp make_pair | |
// Some common useful functions | |
#define MAX(a,b) ((a)>(b)?(a):(b)) | |
#define MIN(a,b) ((a)<(b)?(a):(b)) | |
#define checkbit(n,b) ((n>>b)&1) | |
#define DREP(a) sort(all(a));a.erase(unique(all(a)),a.end()) | |
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin()) | |
/*Faster input functions*/ | |
void scan(int* i){int t=0;char c;bool negative=false;c=getchar_unlocked();while(c<'0'||c>'9'){if(c=='-')negative=true;c=getchar_unlocked();}while(c>='0'&&c<='9'){t=(t<<3)+(t<<1)+c-'0';c=getchar_unlocked();}if(negative)t=~(t-1);*i=t;} | |
void scan(long long int* i){long long int t=0;char c;bool negative=false;c=getchar_unlocked();while(c<'0'||c>'9'){if(c=='-')negative=true;c=getchar_unlocked();}while(c>='0'&&c<='9'){t=(t<<3)+(t<<1)+c-'0';c=getchar_unlocked();}if(negative)t=~(t-1);*i=t;} | |
/*debug functions*/ | |
#ifdef DEBUG | |
#define debug(args...) {dbg,args;std::cerr<<std::endl;} | |
#else | |
#define debug(args...) // Just strip off all debug tokens | |
#endif | |
struct debugger{template<typename T> debugger& operator ,(const T& v){std::cerr<<v<<" ";return *this;}}dbg; | |
template <typename T1,typename T2> inline std::ostream& operator<<(std::ostream& os,const std::pair<T1,T2>& p){return os<<"("<<p.first<<", "<<p.second<<")";} | |
template<typename T>inline std::ostream&operator<<(std::ostream& os,const std::vector<T>& v){bool first=true;std::string delim="[";for(unsigned int i=0;i < v.size();i++){os<<delim<<v[i];delim=", ";}return os<<"]";} | |
template<typename T>inline std::ostream&operator<<(std::ostream& os,const std::set<T>& v){bool first=true;std::string delim="[";for (typename std::set<T>::const_iterator ii=v.begin();ii!=v.end();++ii){os<<delim<<*ii;delim=", ";}return os<<"]";} | |
template<typename T1,typename T2>inline std::ostream&operator<<(std::ostream& os,const std::map<T1,T2>& v){bool first=true;std::string delim="[";for (typename std::map<T1,T2>::const_iterator ii=v.begin();ii!=v.end();++ii){os<<delim<<*ii;delim=", ";}return os<<"]";} | |
/*structs and typedefs*/ | |
int T;/*number of test cases*/ | |
int N,Q;/*integers to be scanned every loop*/ | |
int nums[100000],a,p,q; | |
using namespace std; | |
/*functions*/ | |
int main(int argc, char const *argv[]) | |
{ | |
/* code */ | |
s(T); | |
while(T--) | |
{ | |
s(N);s(Q); | |
forall(i,0,N) | |
s(nums[i]); | |
forall(i,0,Q) | |
{ | |
s(a);s(p);s(q); | |
int max=0; | |
forall(j,p-1,q) | |
max=MAX(max, a^nums[j]); | |
p(max); | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment