QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#362860 | #8515. KMOP | ucup-team3113# | WA | 31ms | 57916kb | C++20 | 1.2kb | 2024-03-23 17:23:48 | 2024-03-23 17:23:50 |
Judging History
answer
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
using namespace std;
const int inf = 1e18;
void p(auto A){
for(auto e : A)cout << e << ' ';
cout << '\n';
}
void solve(){
int n; cin >> n;
vector<string>A(n);
for(int i = 0; i< n; i++)cin >> A[i];
vector<array<int, 3>>dp(n+1, {inf, inf, inf});
auto xmin = [](int& a, int b){a = min(a, b);};
dp[0][0] = 0;
for(int i = 0; i< n; i++){
dp[i+1][1] = dp[i][0] + 1;
dp[i+1][2] = dp[i][1] + 1;
int cons = 0;
for(int j = 0; j< min((int)A[i].size(), (int)3); j++){
if(A[i][j]=='A'||A[i][j]=='E'||A[i][j]=='O'||A[i][j]=='U'||A[i][j]=='Y'){
for(int k = 0; k< 3; k++)if(cons+k<=2){
xmin(dp[i+1][0], dp[i][k] + j + 1);
}
}
else cons++;
}
}
int ans = inf;
xmin(ans, dp[n][0]);
xmin(ans, dp[n][1]);
xmin(ans, dp[n][2]);
if(ans == inf)cout << '*';
else cout << ans;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--)solve();
}
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3796kb
input:
3 KNUTH MORRIS PRATT
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
3 KNUTH M PRATT
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 K M P
output:
*
result:
ok "*"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2 K M
output:
2
result:
ok "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
4 YOU SHOULD BE DANCING
output:
5
result:
ok "5"
Test #6:
score: -100
Wrong Answer
time: 31ms
memory: 57916kb
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 ...
output:
*
result:
wrong answer 1st words differ - expected: '1000000', found: '*'