답안 #1114954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114954 2024-11-19T20:36:51 Z AdamGS JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#ifdef _DEBUG
#define ls(x) << (x) << ", "
#define lv(x) << #x << ": " << flush << (x) << ", "
#define pr(x) cout << "Line: " << __LINE__ << ", " x << endl;
#else
#define ls(x)
#define lv(x)
#define pr(x) ;
#endif
using namespace std;
typedef unsigned int uint;

constexpr char J = 'J';
constexpr char O = 'O';
constexpr char I = 'I';
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    uint n, k;
    cin >> n >> k;
    string a;
    cin >> a;
    uint result = 1e9;
    for (uint i = 0; i < (n - 3*k + 1); i++) {
        if (a[i] != J) continue;
        pr(lv(i) lv(a[i]))
        uint curr = 0;
        uint num_j = 1;
        uint j = i + 1; // not current
        for (; j < n; j++) {
            if (a[j] == J) {
                pr(ls("in j") lv(j) lv(a[j]))
                num_j++;
                if (num_j == k){
                    break;
                }
            } else {
                pr(ls("not j") lv(j) lv(a[j]))
                curr++;
            }
        }
        j++;
        pr(lv(num_j))
        if (num_j < k) {
            break; // już nie będzie
        }
        pr()
        uint num_o = 0;
        for (; j < n; j++) {
            if (a[j] == O) {
                pr(ls("in o") lv(j) lv(a[j]))
                num_o++;
                if (num_o == k) {
                    break;
                }
            } else {
                pr(ls("not o") lv(j) lv(a[j]))
                curr++;
            }
        }
        j++;
        pr(lv(num_o))
        if (num_o < k) {
            break;
        }
        pr()
        uint num_i = 0;
        for (; j < n; j++) {
            if (a[j] == I) {
                pr(ls("in i") lv(i) lv(a[i]))
                num_i++;
                if (num_i == k) {
                    break;
                }
            } else {
                pr(ls("not i") lv(j) lv(a[j]))
                curr++;
            }
        }
        j++;
        pr(lv(num_i))
        if (num_i < k) {
            break;
        }
        pr()
        result = min(result, curr);
    }
    cout << result << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -