Submission #781641

# Submission time Handle Problem Language Result Execution time Memory
781641 2023-07-13T09:06:39 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
100 / 100
5 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
//#define mid (start+end)/2
deque <int> j,o,p;

int32_t main(){
    faster
    int n,k;cin>>n>>k;
    string s;cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='J'){
            j.push_back(i);
        }
        else if(s[i]=='O'){
            o.push_back(i);
        }
        else p.push_back(i);
    }
    //////////////////////////////////////////
    int cev=OYY;
    for(int i=k-1;i<j.size();i++){
        int deg=j[i-k+1];
        int gec=j[i];
        while(!o.empty() && o.front()<gec)o.pop_front();
        if(o.size()<k)continue;

       // cout<<o[k-1]<<endl;
        int m=o[k-1];
        while(!p.empty() && p.front()<m)p.pop_front();
        if(p.size()<k)continue;

        int b=p[k-1];
        int tut=b-deg+1-3*k;
        //cout<<b<<" "<<tut<<endl;
        cev=min(cev,tut);
    }
    if(cev==OYY)cev=-1;
    cout<<cev<<'\n';
    return 0;
}

Compilation message

ho_t2.cpp: In function 'int32_t main()':
ho_t2.cpp:25:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=k-1;i<j.size();i++){
      |                   ~^~~~~~~~~
ho_t2.cpp:29:20: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   29 |         if(o.size()<k)continue;
      |            ~~~~~~~~^~
ho_t2.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::deque<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |         if(p.size()<k)continue;
      |            ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 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 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 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 212 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 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 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 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 212 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 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 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 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 212 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 4 ms 2152 KB Output is correct
37 Correct 5 ms 2272 KB Output is correct
38 Correct 5 ms 2272 KB Output is correct
39 Correct 4 ms 2264 KB Output is correct
40 Correct 5 ms 2288 KB Output is correct
41 Correct 5 ms 2392 KB Output is correct
42 Correct 5 ms 2396 KB Output is correct
43 Correct 4 ms 1492 KB Output is correct
44 Correct 3 ms 1888 KB Output is correct
45 Correct 5 ms 2396 KB Output is correct
46 Correct 5 ms 2392 KB Output is correct
47 Correct 5 ms 2324 KB Output is correct
48 Correct 4 ms 2272 KB Output is correct
49 Correct 3 ms 1632 KB Output is correct
50 Correct 5 ms 2392 KB Output is correct
51 Correct 4 ms 2380 KB Output is correct
52 Correct 3 ms 2272 KB Output is correct
53 Correct 3 ms 2272 KB Output is correct
54 Correct 3 ms 2272 KB Output is correct
55 Correct 2 ms 2272 KB Output is correct
56 Correct 3 ms 2272 KB Output is correct