답안 #747719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747719 2023-05-24T14:49:20 Z prairie2022 JJOOII 2 (JOI20_ho_t2) C++14
100 / 100
10 ms 1544 KB
#include <bits/stdc++.h>
//#define int long long
#define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define end {cout << ans; return 0;}
using namespace std;


int main(){
    int n, k, ans = -1;
    string s;
    cin >> n >> k >> s;
    deque<int> dq[3];
    for(int i=0; i<n; i++)
        dq[(s[i]=='I'?2:0)^(s[i]=='O')].push_back(i);
    while(1){
        if(dq[0].size()<k) end
        while(!dq[1].empty() && dq[1].front()<dq[0][k-1]) dq[1].pop_front();
        if(dq[1].size()<k) end
        while(!dq[2].empty() && dq[2].front()<dq[1][k-1]) dq[2].pop_front();
        if(dq[2].size()<k) end
        ans = min((ans==-1)?n:ans, dq[2][k-1]-dq[0][0]+1-k*3);
        dq[0].pop_front();
    }
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:16:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         if(dq[0].size()<k) end
      |            ~~~~~~~~~~~~^~
ho_t2.cpp:18:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |         if(dq[1].size()<k) end
      |            ~~~~~~~~~~~~^~
ho_t2.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if(dq[2].size()<k) end
      |            ~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 296 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 296 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 8 ms 1252 KB Output is correct
37 Correct 9 ms 1508 KB Output is correct
38 Correct 9 ms 1504 KB Output is correct
39 Correct 9 ms 1484 KB Output is correct
40 Correct 8 ms 1508 KB Output is correct
41 Correct 8 ms 1456 KB Output is correct
42 Correct 10 ms 1544 KB Output is correct
43 Correct 5 ms 996 KB Output is correct
44 Correct 6 ms 1252 KB Output is correct
45 Correct 7 ms 1508 KB Output is correct
46 Correct 8 ms 1480 KB Output is correct
47 Correct 7 ms 1508 KB Output is correct
48 Correct 8 ms 1508 KB Output is correct
49 Correct 5 ms 1124 KB Output is correct
50 Correct 8 ms 1508 KB Output is correct
51 Correct 8 ms 1476 KB Output is correct
52 Correct 7 ms 1480 KB Output is correct
53 Correct 7 ms 1484 KB Output is correct
54 Correct 8 ms 1508 KB Output is correct
55 Correct 7 ms 1480 KB Output is correct
56 Correct 7 ms 1508 KB Output is correct