Submission #889905

# Submission time Handle Problem Language Result Execution time Memory
889905 2023-12-20T09:29:37 Z avighna JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k;
  string s;
  cin >> n >> k >> s;

  string target = string(k, 'J') + string(k, 'O') + string(k, 'I');
  ll ptr = 0;
  ll mn = LLONG_MAX, mx = LLONG_MIN;
  for (ll i = 0; i < n; ++i) {
    if (s[i] == target[ptr]) {
      mn = min(mn, i);
      mx = max(mx, i);
      ptr++;
    }
  }

  if (ptr != target.length()) {
    cout << "-1\n";
  } else {
    cout << mx - mn + 1 - 3 * k << "\n";
  }
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:26:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   if (ptr != target.length()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -