QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#382068 | #8515. KMOP | kevinshan# | WA | 59ms | 101580kb | C++17 | 1.8kb | 2024-04-08 01:51:18 | 2024-04-08 01:51:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("input.in", "r")) {
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
}
int n; cin>>n;
vector<string> ar;
for(int i=0; i<n; i++) {
string s; cin>>s;
ar.pb(s);
}
int cost[n][3];
for(int i=0; i<n; i++) cost[i][0] = cost[i][1] = cost[i][2] = 2e8;
set<char> vowels;
vowels.insert('A');
vowels.insert('E');
vowels.insert('I');
vowels.insert('O');
vowels.insert('U');
vowels.insert('Y');
for(int i=0; i<n; i++){
int cur = 0;
for(int j=0; j<ar[i].size(); j++){
if(j == 3) break;
if(vowels.find(ar[i][j]) != vowels.end()) cur = 0;
else cur++;
if(cur == 1) {
cost[i][1] = min(cost[i][1], j+1);
}
else if(cur == 0) {
cost[i][0] = min(cost[i][0], j+1);
}
else if(cur == 2) {
cost[i][2] = min(cost[i][2], j+1);
}
else break;
}
}
vector<vector<int>> dp(n, vector<int>(3,2e8));
dp[0][0] = cost[0][0];
dp[0][1] = cost[0][1];
dp[0][2] = cost[0][2];
for(int i=1; i<n; i++){
dp[i][0] = min(dp[i][0], min({dp[i-1][0], dp[i-1][1], dp[i-1][2]}) + cost[i][0]);
dp[i][1] = min(dp[i][1], dp[i-1][0] + cost[i][1]);
dp[i][2] = min(dp[i][2], min(dp[i-1][0] + cost[i][2], dp[i-1][1] + cost[i][1]));
}
int res = min({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
if(res >= 2e8) cout<<'*';
else cout<<res;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
3 KNUTH MORRIS PRATT
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
3 KNUTH M PRATT
output:
5
result:
ok "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
3 K M P
output:
*
result:
ok "*"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 K M
output:
2
result:
ok "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
4 YOU SHOULD BE DANCING
output:
5
result:
ok "5"
Test #6:
score: 0
Accepted
time: 59ms
memory: 101580kb
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:
1000000
result:
ok "1000000"
Test #7:
score: 0
Accepted
time: 2ms
memory: 5332kb
input:
1 XAJFUEEIIUOQRUJKBDJUWYSAKPTOCXEUYMYGDOKOAGKXUYPYJYALCCXMPWSAUETUHBAOAIYIGKFLGUJVVNQOANJOYIYTXYNAIKAPEIAHVHQZINSOYPJLEBIJOGNAYWFUEIFDSNLSYEXYYAYZRTEUUEFXBUMOQIYESPKYTACAUXFLYIUYIDOUGOADUHKWOHEIEYUWENJPTOOIXMGAWOYZBMLUAKSIUEUEEECSUAFILCXIOOYIIYNMGYATUAIMZUCHXAKIUVALUMFIEUWUKWFRWALUYIDEQKNAETXEWETEGA...
output:
1
result:
ok "1"
Test #8:
score: -100
Wrong Answer
time: 41ms
memory: 36636kb
input:
333333 SNE NGO NJA JCE XMU WBE ZZO LTY RHY XZU XZY HXI ZPU FWE HLA BFE NHY ZPE WJO QVU KGY DLA BDI CSY WXU XGU GQE CTY WQU FHI KLY PCI VDO BQA WCU KQE FLA TCI PHO GDU RCO PKI HFU MVA SRA KGO JTI NNE RLU LDU DGE QVI GXE BHU CSA PMY LTU HLE MXY QFY STE WXI XPA PKE DBI GTY XVU MXO JRA RNO FZI RFI NGA Q...
output:
555555
result:
wrong answer 1st words differ - expected: '999995', found: '555555'