QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#380498 | #8515. KMOP | corneas | TL | 0ms | 3640kb | C++14 | 843b | 2024-04-07 04:55:45 | 2024-04-07 04:55:46 |
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() && ans == ""; ++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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
3 KNUTH MORRIS PRATT
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
3 KNUTH M PRATT
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 K M P
output:
*
result:
ok "*"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
2 K M
output:
2
result:
ok "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3488kb
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 ...