QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#738189#9568. Left Shifting 3kazimiyuukaCompile Error//C++20702b2024-11-12 18:11:362024-11-12 18:11:37

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 18:11:37]
  • 评测
  • [2024-11-12 18:11:36]
  • 提交

answer

#include <iostream> #include <vector> using namespace std; void slove() { int n, k; cin >> n >> k; k = min(n, k); string str; cin >> str; if (str.size() >= 7) { for (int i = 0; i < 6; i++) { str.push_back(str[i]); } } vector<int> in(str.size(), 0); int cnt = 0; for (int i = 0; i + 6 < str.size(); i++) { if (str.substr(i, 7) == "nanjing") { cnt++; for (int j = 1; j < 6; j++) in[i + j] = 1; } } if (str.size() >= 7) { for (int i = 0; i < 6; i++) { in[i] = in[str.size() - 6 + i]; } } for (int i = 0; i <= k; i++) { if (!in[i]) { cout << cnt << "\n"; return; } } cout << (cnt - 1) << "\n"; return; } int main() { // freopen("in.txt" , "r" , stdin); int cnt = 1; cin >> cnt; while (cnt--) { slove(); } }

詳細信息

answer.code:1:21: warning: extra tokens at end of #include directive
    1 | #include <iostream> #include <vector> using namespace std; void slove() { int n, k; cin >> n >> k; k = min(n, k); string str; cin >> str; if (str.size() >= 7) { for (int i = 0; i < 6; i++) { str.push_back(str[i]); } } vector<int> in(str.size(), 0); int cnt = 0; for (int i = 0; i + 6 < str.size(); i++) { if (str.substr(i, 7) == "nanjing") { cnt++; for (int j = 1; j < 6; j++) in[i + j] = 1; } } if (str.size() >= 7) { for (int i = 0; i < 6; i++) { in[i] = in[str.size() - 6 + i]; } } for (int i = 0; i <= k; i++) { if (!in[i]) { cout << cnt << "\n"; return; } } cout << (cnt - 1) << "\n"; return; } int main() { // freopen("in.txt" , "r" , stdin); int cnt = 1; cin >> cnt; while (cnt--) { slove(); } }
      |                     ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status