1001#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
char a[1000000];
char b[1000000];
int count(int n,int s,int x,int y){
if(x + y > n + s)
return 0;
if(abs(x-y) > n-s)
return 0;
return 1;
}
int main(){
int t,n,x,y;
cin>>t;
while(t--){
cin>>n>>x>>y;
scanf("%s",a);
scanf("%s",b);
int same = 0;
for(int i = 0;i < n; i++){
if(a[i] == b[i])
same++;
}
if(count(n,same,x,y) == 1) cout<<"Not lying"<<endl;
else cout<<"Lying"<<endl;
}
}
1003
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define maxn 250007
int ans[maxn];
int tree[maxn];
int get(int p){
int ans = 0;
while(p < maxn){
ans = max(ans,tree[p]);
p +=(p&(-p));
}
return ans;
}
void set(int p,int d){
while(p > 0){
tree[p] = max(tree[p],d);
p-=(p&-p);
}
}
int a[maxn];
int b[maxn];
int c[maxn];
int main(){
int t;
while(cin>>t){
memset(tree,0,sizeof(tree));
for(int i = 0;i < t; i++){
scanf("%d",&a[i]);
}
for(int j = 0;j < t; j++)
scanf("%d",&b[j]);
int p = t ;
sort(b,b+t);
for(int j = t-1;j >=0;j--){
while(p>=b[j]){
set(p,a[p-1]-p);
p--;
}
c[j] = get(b[j]);
// cout<<c[j]<<endl;
}
sort(c,c+t);
int maxv = 0;
p = t-1;
long long ans = 0;
for(int i = 0;i < t; i++){
int u = max(maxv,c[p]);
ans += u;
maxv = max(maxv,u-(t+1+i));
p--;
}
cout<<ans%1000000007<<endl;
}
}