#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii std::pair<int,int>
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
std::mt19937 myrand(std::chrono::high_resolution_clock::now().time_since_epoch().count());
inline int R(int n){return myrand()%n+1;}
inline int read(){char ch=getchar();int x=0,f=1;for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
const int N=1e6+10,mod=998244353,inf=1e9;
inline void Min(int &x,int y){if(x>y)x=y;}
inline void Max(int &x,int y){if(x<y)x=y;}
int cnt,n,q,a[N],b[N],w[N];
signed main(){
while(1){
system("./rand");
freopen("in.in","r",stdin);
system("./C");
n=read(),q=read();for(int i=1;i<=n;++i)w[i]=read();
for(int i=1;i<=q;++i){
a[i]=read(),b[i]=read();
}
freopen("out.out","r",stdin);
for(int i=1;i<=q;++i){
int k=read();
if(k<0)continue;
assert(((w[k]^a[i])-b[i])*((w[k+1]^a[i])-b[i])<=0);
}
std::cout<<"AC"<<++cnt<<'\n';
}
// q=1e5;
// freopen("std.out","r",stdin);
// for(int i=1;i<=n;++i)a[i]=read();
// freopen("out.out","r",stdin);
// for(int i=1;i<=n;++i){
// int x=read();
// if(a[i]<0||x<0)assert(a[i]==-1&&x==-1);
// }
// std::cout<<"Yes\n";
}
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii std::pair<int,int>
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
std::mt19937 myrand(std::chrono::high_resolution_clock::now().time_since_epoch().count());
inline int read(){char ch=getchar();int x=0,f=1;for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
const int N=1e6+10,mod=998244353,inf=1e9;
inline void Min(int &x,int y){if(x>y)x=y;}
inline void Max(int &x,int y){if(x<y)x=y;}
int n,Q,w[N];
signed main(){
freopen("in.in","r",stdin);freopen("std.out","w",stdout);
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
n=read();Q=read();for(int i=1;i<=n;++i)w[i]=read();
while(Q--){
int a=read(),b=read();
int res=0;
for(int i=1;i<=n;++i){if((w[i]^a)==b){res=i;break;}}
if(res){Min(res,n-1);std::cout<<res<<'\n';continue;}
for(int i=1;i<n;++i){if(((w[i]^a)-b)*((w[i+1]^a)-b)<0){res=i;break;}}
if(!res)res=-1;
std::cout<<res<<'\n';
}
}
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii std::pair<int,int>
#define eb emplace_back
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
std::mt19937 myrand(std::chrono::high_resolution_clock::now().time_since_epoch().count());
inline int R(int n){return myrand()%n+1;}
inline int read(){char ch=getchar();int x=0,f=1;for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);return x*f;}
const int N=2e5+10,mod=998244353,inf=1e9;
inline void Min(int &x,int y){if(x>y)x=y;}
inline void Max(int &x,int y){if(x<y)x=y;}
signed main(){
// freopen("in.in","r",stdin);
freopen("in.in","w",stdout);
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
int n=10000,q=10000;
std::cout<<n<<' '<<q<<'\n';
for(int i=1;i<=n;++i)std::cout<<R(inf)<<' ';std::cout<<'\n';
for(int i=1;i<=q;++i){
std::cout<<R(inf)<<' '<<R(inf)<<'\n';
}
}
标签:std,讲课费,ch,int,峰峻,记录卡,long,inline,define
From: https://www.cnblogs.com/Ishar-zdl/p/18533659