Submission #1114954

#TimeUsernameProblemLanguageResultExecution timeMemory
1114954AdamGSJJOOII 2 (JOI20_ho_t2)C++17
0 / 100
1 ms336 KiB
#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'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...