QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#461784 | #8817. Fast Median Transform | Crysfly | Compile Error | / | / | C++17 | 3.2kb | 2024-07-03 01:51:24 | 2024-07-03 01:51:25 |
Judging History
This is the latest submission verdict.
- [2024-07-03 01:51:25]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-03 01:51:24]
- Submitted
answer
// what is matter? never mind.
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 1000005
#define inf 0x3f3f3f3f
int n,m,q,res;
int a[maxn],b[maxn],top[maxn];
struct node{
int l,r;
node(int x=0,int y=0){l=x,r=y;}
bool emp(){return l>r;}
bool in(int x){return l<=x && x<=r;}
int val(int x){return max(l,min(x,r));}
void swp(){if(l>r)swap(l,r);}
};
node operator +(node a,node b){
return node(max(a.l,b.l),min(a.r,b.r));
}
node tr[maxn<<2],tmp[maxn];
void up(int p){
tr[p]=tr[p<<1]+tr[p<<1|1];
}
void build(int p,int l,int r){
if(l==r) return tr[p]=tmp[l],void();
int mid=l+r>>1;
build(p<<1,l,mid);
build(p<<1|1,mid+1,r); up(p);
}
void mdf(int p,int l,int r,int x){
if(l==r) return tr[p]=tmp[l],void();
int mid=l+r>>1;
x<=mid?mdf(p<<1,l,mid,x):mdf(p<<1|1,mid+1,r,x); up(p);
}
int bound(int p,int l,int r,node t=node(0,1<<29)){
if(l==r)return t.val(tmp[l].l);
int mid=l+r>>1;
if((t+tr[p<<1|1]).emp()) return bound(p<<1|1,mid+1,r,t);
return bound(p<<1,l,mid,t+tr[p<<1|1]);
}
int t[maxn],len;
int fa[maxn];
int idb[maxn];
int gf(int x){
while(x!=fa[x])x=fa[x]=fa[fa[x]];
return x;
}
int col[maxn];
void update(int x,int y){
a[x]=y;
int p=((x-n)%m+m)%m;
tmp[x]=node(a[x],b[p]),tmp[x].swp();
mdf(1,0,n-1,x);
}
int ask(int x){
if(tr[1].emp()) return bound(1,0,n-1);
auto chk=[&](int k,int p){
if(k<tr[1].l)return 0;
if(k>tr[1].r)return 1;
// int p=upper_bound(t+1,t+len+1,k)-t-1;
// cout<<"chk "<<k<<" "<<p<<"\n";
if(col[p]==-1) return x<=k;
int pos=col[p];
return a[pos]<=k;
};
int l=1,r=len;
while(l<r){
int mid=l+r>>1;
if(chk(t[mid],mid))r=mid;
else l=mid+1;
}
int pos=max(0,l-1);
l=t[pos],r=t[pos+1]-1;
while(l<=r){
int mid=l+r>>1;
if(chk(mid,pos))r=mid;
else l=mid+1;
}
return l;
}
signed main()
{
n=read(),m=read(),q=read();
For(i,0,n-1)a[i]=read();
For(i,0,m-1)b[i]=read();
Rep(i,n-1,0){
int x=((i-n)%m+m)%m;
tmp[i]=node(a[i],b[x]),tmp[i].swp();
}
build(1,0,n-1);
For(i,0,m-1)t[++len]=b[i];
sort(t+1,t+len+1),len=unique(t+1,t+len+1)-t-1;
For(i,0,m-1) idb[i]=lower_bound(t+1,t+len+1,b[i])-t;
For(i,0,len+1) fa[i]=i,col[i]=-1;
Rep(i,n-1,min(0,n-1-m*2)){
int x=((i-n)%m+m)%m;
int y=((x-n)%m+m)%m;
int is=(i%n+n)%n;
x=idb[x],y=idb[y];
if(x>y)swap(x,y);
for(x=gf(x);x<y;x=gf(x)) fa[x]=x+1,col[x]=is;
}
For(_,1,q){
int x=read(),y=read()^res,x0=read()^res;
update(x,y);
printf("%d\n",res=ask(x0));
}
return 0;
}
/*
2 3 1
1 3
4 2 3
0 1 2
*/
Details
answer.code: In lambda function: answer.code:94:40: error: inconsistent types ‘int’ and ‘bool’ deduced for lambda return type 94 | if(col[p]==-1) return x<=k; | ~^~~ answer.code:96:30: error: inconsistent types ‘int’ and ‘bool’ deduced for lambda return type 96 | return a[pos]<=k; | ~~~~~~^~~