思路:
判断不可行的条件。输入n,a,b,分别代表n的长度,分数a,分数b。same代表相同的个数。
1. 当a或b 大于n 时 不可行。
2.
(a−same)+(b−same)+same<=n
不满足这个的一定误解
3. 考虑当a大于notsame时,我们发现这时需要a-notsame个相同的题得正确。所以b需要大于等于a-notsame,同时b需要小于
n−(a−same)
,反之亦然。
#include<iostream>
#include<cstdio>
#include <queue>
#include<cstring>
#include<cmath>
#define inf 1e15
#define eps 1e-6
typedef long long int lli;
using namespace std;
char s1[180000];
char s2[180000];
int main(){
int cas,a,b,len;
scanf("%d",&cas);
while(cas--){
scanf("%d%d%d",&len,&a,&b);
scanf("%s",s1);
scanf("%s",s2);
int same = 0,notsame = 0,flag = 1;
for(int i = 0;s1[i];i++){
if(s1[i] == s2[i]) same++;
else notsame++;
}
if(a>notsame){
if(b>=a-notsame && b<=same+len-a);
else flag = 0;
}
if(b>notsame){
if(a>=b-notsame && a<=same+len-b);
else flag = 0;
}
if(a>len || b>len) flag = 0;
if(a+b-same > len) flag = 0;
if(!flag)
puts("Lying");
else
puts("Not lying");
}
}