这玩意对于 n>3 且 s.size>n 的情况只会输出 yes。就这种毫无正确性的东西也能过?
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
string s;
int dp[2005][2005];
int getLIS(string x,string y){
memset(dp,0,sizeof(dp));
x = " " + x;
y = " " + y;
for(int i = 1;i < x.size();++i) {
for(int j = 1;j < y.size();++j) {
if(x[i] == y[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
else dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]);
}
}
return dp[x.size() - 1][y.size() - 1];
}
string tostring(int x){
if(!x) return "0";
string a;
while(x){
a += (x % 10) + '0';
x /= 10;
}
string b;
for(int i = a.size() - 1;i >= 0;--i)b += a[i];
return b;
}
int toint(string x){
int ans = 0;
for(int i = 0;i < x.size();++i) ans = ans * 10 + (x[i] - '0');
return ans;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
cin >> n >> s;
if(n == 1) {
if((s[s.size()-1] - '0') & 1) cout << "No\n";
else cout << "Yes\n";
}
else if(n == 3){
for(int i = 1;i <= s.size();++i) {
for(int j = 1;j <= s.size() - i;++j) {
string a = s.substr(0,i),b = s.substr(i,j),c = s.substr(i + j,s.size() - i - j);
int x = toint(a),y = toint(b),z = toint(c);
int A1 = x + z - y,A2 = x + y - z,A3 = y + z - x;
string ss = tostring(A1 / 2 + A2 / 2) + tostring(A2 / 2 + A3 / 2) + tostring(A3 / 2 + A1 / 2);
if((A1 % 2 == 0 && A2 % 2 == 0 && A3 % 2 == 0) && getLIS(ss,s) == ss.size()){
cout << "Yes\n";goto xz;
}
}
}
cout << "No\n";
xz:;
}
else{
if(s.size() < n) cout << "No\n";
else if(s.size() == n) {
bool f = 1;
for(int i = 0;i < s.size();++i) if((s[i] - '0') & 1) f ^= 1;
if(!f) cout << "No\n";
else cout << "Yes\n";
}
else cout <<"Yes\n";
}
}
}