Submission #1023735

#TimeUsernameProblemLanguageResultExecution timeMemory
1023735vjudge1JJOOII 2 (JOI20_ho_t2)C++17
13 / 100
2068 ms860 KiB
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define allr(pon) pon.rbegin(), pon.rend() #define all(pon) pon.begin(), pon.end() #define nosolve cout << "-1\n" #define YES cout << "YES\n" #define Yes cout << "Yes\n" #define pii pair <int, int> #define OK cout << "OK\n" #define Ok cout << "Ok\n" #define NO cout << "NO\n" #define No cout << "No\n" #define pf push_front #define int long long #define pb push_back #define sigma signed #define sc second #define fr first using namespace __gnu_pbds; using namespace std; const int N = 1e6 + 20, INF = 1e16 + 7; int dp[N]; sigma main(){ nemeshay string s; int n, k, ans = INF; cin >> n >> k >> s; for (int i = 0; i < n; i++) { if (s[i] == 'J') { int l = i, r, cntj = 0, cnto = 0, cnti = 0; for (int j = i; j < n; j++) { if (s[j] == 'J') cntj++; if (s[j] == 'O' && cntj >= k) cnto++; if (s[j] == 'I' && cnto >= k && cntj >= k) cnti++; if (cnti == k) { r = j; break; } } if (cntj >= k && cnto >= k && cnti >= k) ans = min(ans, r - l + 1 - 3 * k); } } if (ans == INF) ans = -1; cout << ans; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:43:71: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |             if (cntj >= k && cnto >= k && cnti >= k) ans = min(ans, r - l + 1 - 3 * k);
      |                                                                     ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...