제출 #212521

#제출 시각아이디문제언어결과실행 시간메모리
212521DystoriaXJJOOII 2 (JOI20_ho_t2)C++14
0 / 100
5 ms256 KiB
#include <bits/stdc++.h> using namespace std; int n, k; char s[200010]; vector<int> J, O, I; int lf[200010]; int ans = 1e9; int main(){ scanf("%d%d", &n, &k); scanf(" %s", s + 1); for(int i = 1; i <= n; i++){ if(s[i] == 'J') J.emplace_back(i); if(s[i] == 'O') O.emplace_back(i); if(s[i] == 'I') I.emplace_back(i); } for(int i = k - 1; i < (int) J.size(); i++){ lf[J[i]] = J[i - k + 1]; } for(int i = k - 1; i < (int) O.size(); i++){ auto it = lower_bound(J.begin(), J.end(), O[i - k + 1] - 1); if(it == J.end() || lf[*it] == 0 || *it > O[i]) continue; lf[O[i]] = lf[*it]; } for(int i = k - 1; i < (int) I.size(); i++){ auto it = lower_bound(O.begin(), O.end(), I[i - k + 1] - 1); if(it == O.end() || lf[*it] == 0 || *it > I[i]) continue; ans = min(ans, I[i] - lf[*it] + 1 - 3 * k); } if(ans == 1e9) ans = -1; printf("%d\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
ho_t2.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", s + 1);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...