Is Derek lying?
题意: 给出两人的答案,由你判断 Derek 提供的分数是否真实。
分析:
(1)两人的分数差不会大于两人不相同的题目所占分数;
(2)两人分数和加上不一样的题目的分数不会比两张卷子总分2 * n 大。
如果上面两条有一条不符合,那么就有假。
代码如下:
#include <bits/stdc++.h
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int M = 1e5+7;
string c1,c2;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int T;
cin>>T;
while(T--){
int N,X,Y;
cin>>N>>X>>Y;
cin>>c1;
cin>>c2;
int cnt=0;
for(int i=0;i<N;i++){
if(c1[i] != c2[i])cnt++;
}
if(fabs(X - Y) <= cnt && (X + Y + cnt)<= 2*N )cout<< "Not lying" <<endl;
else cout<< "Lying" <<endl;
}
return 0;
}
JUN WYC