# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
889955 | avighna | JJOOII 2 (JOI20_ho_t2) | C++17 | 2047 ms | 860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ans = LLONG_MAX;
for (ll j = 0; j < n; ++j) {
ll ptr = 0;
ll mn = LLONG_MAX, mx = LLONG_MIN;
for (ll i = j; i < n; ++i) {
if (s[i] == target[ptr]) {
mn = min(mn, i);
mx = max(mx, i);
ptr++;
}
}
if (ptr == target.length()) {
ans = min(ans, mx - mn + 1 - 3 * k);
}
}
if (ans == LLONG_MAX) {
cout << "-1\n";
} else {
cout << ans << "\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |