답안 #1023708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023708 2024-07-15T05:14:18 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 344 KB
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define vec vector
#define int long long
#define inf 1e18
const int mod = 998244353 , men = 1e9 + 7;
/*
▀█████████▄   ▄█   ▄█          ▄████████  ▄█        ▄████████  ▄██████▄  ████████▄     ▄████████    ▄████████ 
  ███    ███ ███  ███         ███    ███ ███       ███    ███ ███    ███ ███   ▀███   ███    ███   ███    ███ 
  ███    ███ ███▌ ███         ███    ███ ███       ███    █▀  ███    ███ ███    ███   ███    █▀    ███    ███ 
 ▄███▄▄▄██▀  ███▌ ███         ███    ███ ███       ███        ███    ███ ███    ███  ▄███▄▄▄      ▄███▄▄▄▄██▀ 
▀▀███▀▀▀██▄  ███▌ ███       ▀███████████ ███       ███        ███    ███ ███    ███ ▀▀███▀▀▀     ▀▀███▀▀▀▀▀   
  ███    ██▄ ███  ███         ███    ███ ███       ███    █▄  ███    ███ ███    ███   ███    █▄  ▀███████████ 
  ███    ███ ███  ███▌    ▄   ███    ███ ███▌    ▄ ███    ███ ███    ███ ███   ▄███   ███    ███   ███    ███ 
▄█████████▀  █▀   █████▄▄██   ███    █▀  █████▄▄██ ████████▀   ▀██████▀  ████████▀    ██████████   ███    ███ 
				  ▀                      ▀                                                         ███    ███ 
*/
template<typename _T>
bool chmin(_T &a, const _T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename _T>
bool chmax(_T &a, const _T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
double dist(double x1 , double y1 , double x2 , double y2){
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));	
}
inline void io(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}
inline void solve(){
	int n , k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 1e9;
	for (int mask = 0; mask < (1 << n); mask++){
		int l = n , r = 0;
		string c = "";
		for (int i = 0; i < n; i++){
			if (mask & (1 << i)){
				c += s[i];
				chmin(l , i);
				chmax(r , i);
			}
		}
		if (c[0] == 'J'){
			string x = "J";
			for (int i = 1; i < (int)c.size(); i++)
				if (c[i] != c[i - 1])
					x += c[i];
			if (x == "JOI" && (r - l + 1) - (k * 3) > 0)
				chmin(ans , (r - l + 1) - (k * 3) + 1);
		}
	}
	cout << (ans != 1e9 ? ans : -1) << "\n";
}
signed main() {
	io();
    int t = 1;
    //~ cin >> t;
    while(t--)
        solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -