Submission #781575

# Submission time Handle Problem Language Result Execution time Memory
781575 2023-07-13T08:14:52 Z vjudge1 JJOOII 2 (JOI20_ho_t2) C++17
1 / 100
2000 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 200005
int arr[N];
string str;
int n,k;
ll int aw(int bas,int cur,int nerdeyim,int nerdeydim,int j,int owo,int uwu){
	//cout<<bas<<" "<<cur<<" "<<nerdeyim<<" "<<nerdeydim<<" "<<j<<" "<<owo<<" "<<uwu<<endl;
	if(nerdeyim>=n){
		if(j==k&&owo==k&&uwu==k)return cur;
		else return 1000000000;
	}
	ll int a,b=1000000000;
	a=aw(bas,cur,nerdeyim+1,nerdeydim,j,owo,uwu);
	if(str[nerdeyim]!='J'&&bas==0){
		return a;
	}
	if(bas==0){
		b=aw(1,cur,nerdeyim+1,nerdeyim,j+1,owo,uwu);
		return min(a,b);
	}
	if(bas==1){
		int deg1=j,deg2=owo,deg3=uwu;
		if(str[nerdeyim]=='J')deg1=j+1;
		if(str[nerdeyim]=='O'&&j==k)deg2=owo+1;
		if(str[nerdeyim]=='I'&&j==k&&owo==k)deg3=uwu+1;
		if(deg1!=j||deg2!=owo||deg3!=uwu)b=aw(bas,cur+(nerdeyim-nerdeydim-1),nerdeyim+1,nerdeyim,deg1,deg2,deg3);
	}
	return min(a,b);

}
int main(){
	cin>>n>>k;
	cin>>str;
	ll int a=aw(0,0,0,0,0,0,0);
	if(a>=1000000000)a=-1;
	cout<<a<<endl;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Execution timed out 2063 ms 468 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Execution timed out 2063 ms 468 KB Time limit exceeded
16 Halted 0 ms 0 KB -