Submission #781677

# Submission time Handle Problem Language Result Execution time Memory
781677 2023-07-13T09:49:33 Z vjudge1 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 17
int n;
int arr[N];
ll int hesap(int nerdeyim,int kac,int lop){
	if(lop==5)return 1000000000;
	int yes=0;
	for(int i=0;i<n-1;i++){
		if(arr[i]==arr[i+1]){yes=1;break;}
	}
	if(yes==0)return kac;
	if(nerdeyim>=n-1){
		return hesap(0,kac,lop+1);
	}
	ll int a=1000000000;
	ll int b=1000000000;
	if(arr[nerdeyim]==arr[nerdeyim+1]){
		swap(arr[nerdeyim],arr[nerdeyim+1]);
		b=hesap(nerdeyim+1,kac+1,lop);
		swap(arr[nerdeyim],arr[nerdeyim+1]);
	}
	else{
		a=hesap(nerdeyim+1,kac,lop);
	}
	return min(a,b);
}
int main(){
	lalala;
	cin>>n;
	string str;cin>>str;
	for(int i=0;i<n;i++){
		if(str[i]=='G')arr[i]=1;
		if(str[i]=='Y')arr[i]=2;
	}
	ll int a=hesap(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 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 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 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 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 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -