1 条题解
-
0
#include <iostream> #include <string> #include<vector> using namespace std; int main() { //屎山代码 string word, article; getline(cin, word); getline(cin, article); int count = 0, pos = -1; for (int i = 0; i < article.size(); i++) { if (article[i] >= 65 && article[i] <= 90) { article[i] = article[i] + 32; } if (i >= word.size()) continue; if (word[i] >= 65 && word[i] <= 90) { word[i] = word[i] + 32; } } int n = word.size(); if (article.size() > n) word.push_back(' '); for (int i = 0; i < article.size(); i++) { if (article.size() - i - 1 == n) { word.erase(word.end() - 1); } if (article.substr(i, word.size()) == word) { count++; if (pos == -1) { pos = i; } } if (i == 0) word.insert(word.begin(), ' '); } if (count == 0) { cout << "-1" << endl; } else { cout << count << " "; if (pos == 0) cout << pos << endl; else cout << pos + 1 << endl; } return 0; }
- 1
信息
- ID
- 406
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 1855
- 已通过
- 127
- 上传者