题目链接:Is Derek lying?
题目大意:两个人做选择题,只有ABC三种选项,然后现在有A和B两个人手上做的选择题的答案,即是两个字符串,然后给你A和B做对的选择题数量,A的数量一定正确,现在需要你去判断B的数量是否正确,那些题目做对不一定
题目数量:我们可以很容易的想到因为A对的题目一定正确,所以我们可以比较这两个字符串,得到相同的和不同的题数,然后算上界和下界就好了,具体看代码就能懂了
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int t,n,x,y,same,unsame;
string s1,s2;
scanf("%d",&t);
while(t--){
same = unsame = 0;
scanf("%d%d%d",&n,&x,&y);
cin>>s1>>s2;
int l = s1.size();
for(int i = 0;i < l;i++){
if(s1[i] == s2[i]) same++;
else unsame++;
}
int maxx = min(same,x)+(unsame-max(x-same,0));
int minn = max(x-unsame,0);
if(y >= minn&&y <= maxx) puts("Not lying");
else puts("Lying");
}
return 0;
}