답안 #1023707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023707 2024-07-15T05:13:43 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
1 / 100
2000 ms 452 KB
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int mod = 1000000007;
signed main() {
  	ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
   	int n,k;
   	cin>>n>>k;
   	string s;
   	cin>>s;
   	int mn=1e18;
	for(int l=0;l<n;l++){
		string s2="";
		for(int r=l;r<n;r++){
			int ok1=0,ok2=0,ok3=0;
			s2.push_back(s[r]);
			for(int i=0;i<s2.size();i++){
				if(s2[i]=='J'){
					ok1++;
				}
				if(ok1>=k and s2[i]=='O'){
					ok2++;
				}
				if(ok2>=k and s2[i]=='I'){
					ok3++;
				}
			}
			if(ok3>=k){
				mn=min(mn,(r-l+1)-(3*k));
			}
//			cout<<l<<" "<<r<<endl;
//			cout<<s2<<endl<<endl;
		}
	}
	if(mn==1e18){
		cout<<-1;
	}else{
		cout<<mn;
	}
	//  int t;
//  cin>>t;
//  while(t--){
//  int n, m; cin >> n >> m;
////  f.resize(n + 1), inv.resize(n + 1);
////  
////  f[0] = inv[0] = 1;
////  for(int i=1;i<=n;i++){
////    f[i] = f[i - 1] * 1ll * i % mod;
////    
////    inv[i] = binary_power(f[i], mod - 2, mod);
////  }
//  
//  cout<<bin(n,m)<<"\n";
//}
return 0;
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:18:17: 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]
   18 |    for(int i=0;i<s2.size();i++){
      |                ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Execution timed out 2095 ms 348 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Execution timed out 2095 ms 348 KB Time limit exceeded
16 Halted 0 ms 0 KB -