Submission #781677

#TimeUsernameProblemLanguageResultExecution timeMemory
781677vjudge1Growing Vegetable is Fun 3 (JOI19_ho_t3)C++17
0 / 100
1 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...