Submission #1023786

#TimeUsernameProblemLanguageResultExecution timeMemory
1023786vjudge1JJOOII 2 (JOI20_ho_t2)C++17
13 / 100
2057 ms984 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define f first #define s second #pragma GCC optimize("O3") #pragma GCC target("avx2") const int inf = 1e9; using namespace std; void solve() { int n, k; cin >> n >> k; string s; cin >> s; int ans = inf; string s2 = ""; for(int i = 0;i < k;i++) { s2 += 'J'; } for(int i = 0;i < k;i++) { s2 += 'O'; } for(int i = 0;i < k;i++) { s2 += 'I'; } for(int l = 0 ;l < s.size() ; l++) { int cnt1 = 0, cnt2 = 0; for(int r = l;r < s.size();r++) { if(s[r] == s2[cnt1]) { cnt1++; } else { cnt2++; } if(cnt1 == s2.size()) { ans = min(ans, cnt2); break; } } } if (ans == inf) ans = -1; cout << ans; } signed main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); int t = 1; //cin >> t; while (t--) { solve(); } }

Compilation message (stderr)

ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:26:22: 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 |     for(int l = 0 ;l < s.size() ; l++) {
      |                    ~~^~~~~~~~~~
ho_t2.cpp:28:25: 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]
   28 |         for(int r = l;r < s.size();r++) {
      |                       ~~^~~~~~~~~~
ho_t2.cpp:34:21: 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]
   34 |             if(cnt1 == s2.size()) {
      |                ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...