社区讨论
梦游打出的代码,www!!求调
P1308[NOIP 2011 普及组] 统计单词数参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mhke5rhk
- 此快照首次捕获于
- 2025/11/04 17:53 4 个月前
- 此快照最后确认于
- 2025/11/04 17:53 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
int main() {
long long ans, g = 0, cns = 0, cns1 = 10e9, dns = 0, s = 0;
string a, b, c;
getline(cin, b);
getline(cin, a);
for (int i = 0; i < a.size(); i++) {
if (a[i] != ' ') {
c[g] = a[i];
g++;
} else {
g = 0;
cns++;
s = 0;
if (g == b.size()) {
for (int j = 0; j <= g; j++) {
if (b[j] != c[g]) {
s = 1;
}
}
if (s == 0) {
if (cns < cns1) {
cns1 = cns;
}
dns++;
}
}
}
}
if (cns == 10e9 && dns > 0) {
cout << dns << " " << cns1;
}else{
cout<<-1;
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...