QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#380481 | #8515. KMOP | johnsovero | TL | 0ms | 3808kb | C++14 | 762b | 2024-04-07 04:41:56 | 2024-04-07 04:41:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
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){
if(level == n){
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);
}
}
int main(){
cin>>n;
v.resize(n);
for(int i = 0; i < n; ++i){
cin>>s;
v[i] = s.substr(0,3);
}
bt("", 0, 0);
if(ans == "")cout<<'*';
else cout<<ans.size();
cout<<'\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3464kb
input:
3 KNUTH MORRIS PRATT
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
3 KNUTH M PRATT
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
3 K M P
output:
*
result:
ok "*"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 K M
output:
2
result:
ok "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3576kb
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 ...