답안 #1115058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1115058 2024-11-19T23:29:17 Z staszic_ojuz JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;
string wzor, word;

int min_dlug(int ind, int ind_pomoc){
    int dlugosc = 0, min_dlugosc = 200001, druga_dlugosc = 200001;
    bool nie_wywolane = true;
    while(ind < n){
        ind++;
        if(nie_wywolane && ind_pomoc > k && word[ind] == 'J'){
            nie_wywolane = false;
            druga_dlugosc = min_dlug(ind, k + 1);
        }
        if(word[ind] == wzor[ind_pomoc]){
            ind_pomoc++;
            if(ind_pomoc == k * 3){
                return min(dlugosc, druga_dlugosc);
            }
        }else{
            dlugosc++;
        }
    }
    if(nie_wywolane){
        druga_dlugosc = -1;
    }
    return min(-1, druga_dlugosc);

}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    cin >> word;
    for(int i = 0; i < k; i++){
        wzor += "J";
    }
    for(int i = 0; i < k; i++){
        wzor += "O";
    }
    for(int i = 0; i < k; i++){
        wzor += "I";
    }
    int index_1 = 0;
    while(word[index_1] != 'J'){
        index_1++;
    }
    cout << min_dlug(index_1, 1);
}

Compilation message

ho_t2.cpp: In function 'int min_dlug(int, int)':
ho_t2.cpp:8:22: warning: unused variable 'min_dlugosc' [-Wunused-variable]
    8 |     int dlugosc = 0, min_dlugosc = 200001, druga_dlugosc = 200001;
      |                      ^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -