QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#553488#5666. Repetitive Elementsfr1tz#Compile Error//C++17900b2024-09-08 14:09:112024-09-08 14:09:13

Judging History

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

  • [2024-09-08 14:09:13]
  • 评测
  • [2024-09-08 14:09:11]
  • 提交

answer

// REPETITIVE ELEMENTS

#include <bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pp pair<int, int>
#define el '\n'

int main() {
  int t;
  string s, s1, s2;
  cin >> t;
  while (t--) {
    cin >> s;
    bool found = false;
    slen = s.size();
    for (int length = slen/2; length > 0; length--) {
      for (int i = 0; i + length <= slen; i++) {
        checkstring = s.substr(i, length);
        for (int j = i+length; j + length <= slen; j++) {
          comparestring = s.substr(j, length);
          if (checkstring == comparestring) {
            cout << checkstring << el;
            found = true;
            break;
          }
        }
        if (found) break;
      }
      if (found) break;
    }
  }
}

Details

answer.code: In function ‘int main()’:
answer.code:22:5: error: ‘slen’ was not declared in this scope; did you mean ‘wcslen’?
   22 |     slen = s.size();
      |     ^~~~
      |     wcslen
answer.code:25:9: error: ‘checkstring’ was not declared in this scope
   25 |         checkstring = s.substr(i, length);
      |         ^~~~~~~~~~~
answer.code:27:11: error: ‘comparestring’ was not declared in this scope
   27 |           comparestring = s.substr(j, length);
      |           ^~~~~~~~~~~~~