제출 #1231352

#제출 시각아이디문제언어결과실행 시간메모리
1231352dssfsuper2Growing Vegetable is Fun 3 (JOI19_ho_t3)C++20
20 / 100
1096 ms328 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; vector<int> treating; int n; int dpf(vector<int>& treating, int lc){ bitset<3> hs; int res = 1000000000; int ri=0; vector<int> indexe(3); int nbt=0; for(auto thing:treating){ if(thing>=3){ nbt++; } } int tnt=0; if(nbt==n)return 0; for(int i = 0;i<n;i++){ int thing = treating[i]; if (thing<3 && !hs[thing] && thing!=lc){ hs[thing]=1; treating[i]+=3; res=min(res, dpf(treating, thing)+tnt); nbt++; treating[i]-=3; } if(thing<3)tnt++; } return res; } //ok no I put in treating a big 4 to say it has been treated and order kepts int main(){ cin>>n; for(int i = 0;i<n;i++){ char x;cin>>x; if(x=='R'){ treating.push_back(0); } if(x=='G'){ treating.push_back(1); } if(x=='Y'){ treating.push_back(2); } } int x = dpf(treating, -1); cout << (x==1000000000? -1 : x); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...