c++ - 代码一起询问所有测试用例的输入,而不是一个一个地为每个测试用例提供输出
问题描述
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--){
int n, k;
cin >> n >> k;
string s="", subs(k, '*');
cin >> s;
size_t found = s.find(subs);
if(found!=string::npos){
cout << "YES" << "\n";
}
else{
cout << "NO" << "\n";
}
}
return 0;
}
此代码一次获取所有测试用例的输入,而不是输入一个测试用例并为其提供输出,然后询问下一个测试用例的输入。
解决方案
推荐阅读
- c# - 使用代理检查互联网连接状态
- java - 使用 excel .xls,是否有其他方法可以执行以下操作?
- c# - Windows 服务不会等待正在运行的任务完成
- c# - 获取 SBObject 实例的真实类型
- c - c - fread 后以 hexa 格式打印文件
- kotlin - KoinTest 类中的 startKoin 抛出“A KoinContext 已启动”
- python-3.x - 以递归方式将字符串中的 'pi' 替换为 '3.14' [未通过测试用例]
- javascript - 如何使用 API 中的数据从日期选择器中获取价值
- php - 循环通过一个 php 数组 => 奇怪
- angularjs - 我如何在 ionic 1 项目中导入 Howler