General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
38236267 Contestant:
Kawaya
979D - 19 GNU C++11 Accepted 46 ms 3740 KB 2018-05-14 18:51:29 2018-05-14 20:39:50
 
 
→ Source
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=300000;

int Q; bool vis[MAXN+1];

int main(){
	Q=read();
    while(Q--){
    	int opr=read();
    	if(opr==1){
    		int u=read(); vis[u]=true;
		}
		else{
			int x=read(),k=read(),s=read();
			if(x%k!=0){puts("-1"); continue;}
			int ans=-INF,tmp=0; int c=(int)((s-x)/k)*k;
			for(int i=c;i>=1;i-=k){
			    if(ans&&tmp-i>(x<<1)) break; 
				if(vis[i]&&(x^i)>ans) ans=x^i,tmp=i;
			}
			//for(int i=k;i<=s-x;i+=k){ if(vis[i]&&(x^i)>ans) ans=x^i,tmp=i; }
			if(tmp) printf("%d\n",tmp);
			else printf("-1\n");
		}
	}
	return 0;
}

 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details