답안 #927620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927620 2024-02-15T07:31:50 Z Aiperiii JJOOII 2 (JOI20_ho_t2) C++14
13 / 100
2000 ms 860 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    string s;cin>>s;
    int mn=1e9;
    string t="";
    for(int i=0;i<k;i++)t+='J';
    for(int i=0;i<k;i++)t+='O';
    for(int i=0;i<k;i++)t+='I';
    for(int i=0;i<s.size();i++){
        if(s[i]=='J'){
            int pos=0,cnt=0;
            for(int j=i;j<s.size();j++){
                if(s[j]==t[pos])pos++;
                else cnt++;
                if(pos==t.size()){
                    mn=min(mn,cnt);
                    break;
                }
            }
        }
    }
    if(mn==1e9)mn=-1;
    cout<<mn<<"\n";
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:17:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
ho_t2.cpp:20:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int j=i;j<s.size();j++){
      |                         ~^~~~~~~~~
ho_t2.cpp:23:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                 if(pos==t.size()){
      |                    ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 440 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 440 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 448 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 440 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 448 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 5 ms 856 KB Output is correct
37 Correct 5 ms 860 KB Output is correct
38 Correct 5 ms 860 KB Output is correct
39 Execution timed out 2091 ms 860 KB Time limit exceeded
40 Halted 0 ms 0 KB -