이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K;
string S;
vector<ll> J, O, I;
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N >> K >> S;
S = " " + S;
for(ll i = 1; i <= N; i++){
if(S[i] == 'J') J.push_back(i);
if(S[i] == 'O') O.push_back(i);
if(S[i] == 'I') I.push_back(i);
}
ll t = 1e18;
for(ll i = 1; i <= N; i++){
ll p = lower_bound(J.begin(), J.end(), i) - J.begin() + K - 1;
if(p >= J.size()) continue;
ll q = lower_bound(O.begin(), O.end(), J[p]) - O.begin() + K - 1;
if(q >= O.size()) continue;
ll r = lower_bound(I.begin(), I.end(), O[q]) - I.begin() + K - 1;
if(r >= I.size()) continue;
t = min(t, I[r] - i + 1 - 3 * K);
}
cout << (t == 1e18 ? -1 : t);
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t2.cpp: In function 'int main()':
ho_t2.cpp:22:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if(p >= J.size()) continue;
| ~~^~~~~~~~~~~
ho_t2.cpp:25:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | if(q >= O.size()) continue;
| ~~^~~~~~~~~~~
ho_t2.cpp:28:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if(r >= I.size()) continue;
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |