QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#380491 | #8515. KMOP | corneas | TL | 1ms | 3772kb | C++14 | 830b | 2024-04-07 04:47:28 | 2024-04-07 04:47:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
string s, ans = "";
vector<string> v;
bool isVowel(char c){
return (c=='U'||c=='A'||c=='O'||c=='I'||c=='E'|| c=='Y');
}
void bt(string ss, int level, int freq, int &nn){
if(level == nn){
if(ans == "")ans = ss;
else if(ans.size() > ss.size())ans = ss;
return;
}
for(int i = 0; i < v[level].size(); ++i){
ss += v[level][i];
if(isVowel(v[level][i]))freq = 0;
else ++freq;
if(freq < 3)bt(ss, level + 1, freq, nn);
else return;
}
}
int main(){
int n;
cin>>n;
for(int i = 0; i < n; ++i){
cin>>s;
v.push_back(s.substr(0,3));
}
bt("", 0, 0, n);
if(ans == "")cout<<'*';
else cout<<ans.size();
cout<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
3 KNUTH MORRIS PRATT
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
3 KNUTH M PRATT
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
3 K M P
output:
*
result:
ok "*"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2 K M
output:
2
result:
ok "2"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
4 YOU SHOULD BE DANCING
output:
5
result:
ok "5"
Test #6:
score: -100
Time Limit Exceeded
input:
1000000 Y E U O I E I E E Y I I E Y E U U O A I U O Y I Y Y U A O E U I A U U I A I U A Y I E U I O Y U Y Y I E O Y E A U O O I A E I I Y U A E Y Y A O O Y A U E A O I O Y A E I U I E Y O U O I I Y E I A Y U I I Y E E U O O U A I Y A I I E O O A A I U I U O E U I E A O E A I O O Y I U U A I A Y O A ...