Submission #922324

# Submission time Handle Problem Language Result Execution time Memory
922324 2024-02-05T12:10:07 Z elotelo966 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
500 ms 452 KB
    #include <bits/stdc++.h>
   using namespace std;
   #define int long long
   #define OYY LLONG_MAX
   #define mod 998244353
   #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   #define mid (start+end)/2
   #define lim 65
   #define fi first
   #define se second
   int n;// 1 2 3
   int cev=LLONG_MAX;
   bool stop=true;
   string s;
   
   inline void dpp(int mask,int tut,string st){
	   int deg=__builtin_popcount(mask);
	   if(deg==n){
		   cev=min(cev,tut);
		  stop=true; 
		}
    	for(int i=0;i<n;i++){
			if(mask&(1<<i))continue;
			if(st.size()>0 && s[i]==st.back())continue;
			dpp(mask|(1<<i),tut+abs(deg-i),st+s[i]);
		}
   }
     
int32_t main(){
    faster
    cin>>n>>s;
    string st="";
    dpp(0,0,st);
    if(stop==false)cout<<-1<<'\n';
    else cout<<cev/2<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 27 ms 452 KB Output is correct
5 Execution timed out 1052 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 27 ms 452 KB Output is correct
5 Execution timed out 1052 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 1070 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 27 ms 452 KB Output is correct
5 Execution timed out 1052 ms 348 KB Time limit exceeded
6 Halted 0 ms 0 KB -