样例都过,20分
查看原帖
样例都过,20分
1356734
huyouxi楼主2025/1/6 20:20

救命

#include<bits/stdc++.h>

using namespace std;

int main() {
    int t, n, m, a = 0, b = 0;
    cin >> t;
    string s;
    for (int i = 0; i < t; i++) {
        cin >> n >> m >> s;
        if (s[0] == '0') {
            cout << "No\n";
            continue;
        }
        for (int j = 0; j < m; j++) {
            b++;
            if (s[j] == '1') {
                a++;
            }
            if (a == 2) {
                break;
            }
        }
        if (n - b >= 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}

2025/1/6 20:20
加载中...