QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350703#8244. Digit TranslationHaidy_YasserWA 87ms148892kbC++141.2kb2024-03-11 01:11:092024-03-11 01:11:11

Judging History

你现在查看的是最新测评结果

  • [2024-03-11 01:11:11]
  • 评测
  • 测评结果:WA
  • 用时:87ms
  • 内存:148892kb
  • [2024-03-11 01:11:09]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define endl '\n'
using namespace std;
void Haidy();

int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
const int MOD = int(1e9 + 7);

string s;
int n;
vector<int> dp;
set<string> num = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
ll cnt = 1;
ll mod = 9302023;
ll rec(ll i){
    if(i == n) return 0;
    if(~dp[i]) return dp[i];
    ll a1, a2;
    a1 = a2 = 1e9;
    for(int j = 3; j <= 5; j++){
        if(i + j <= n){
            string sub = s.substr(i, j);
            if(num.count(sub)){
                a1 = rec(i + j) + 1;
            }
        }
    }
    a2 = rec(i + 1) + 1;
    if(a1 == a2)
        cnt = (cnt * 2) % mod;
    return dp[i] = min(a1, a2);
}

void solveTest() {
    cin >> s;
    n = s.size();
    dp.assign(n+2, -1);
    cout << rec(0) << endl;
    cout << cnt;
}

int main() {
    Haidy();
    int testCases = 1;
//    cin >> testCases;
    while(testCases--)
        solveTest();
    return 0;
}

void Haidy()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3840kb

input:

icecreamcone

output:

10
1

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

onetwo

output:

2
1

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

twone

output:

3
2

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

a

output:

1
1

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

zero

output:

1
1

result:

ok 2 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

one

output:

1
1

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

two

output:

1
1

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

three

output:

1
1

result:

ok 2 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

four

output:

1
1

result:

ok 2 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

five

output:

1
1

result:

ok 2 lines

Test #11:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

six

output:

1
1

result:

ok 2 lines

Test #12:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

seven

output:

1
1

result:

ok 2 lines

Test #13:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

eight

output:

1
1

result:

ok 2 lines

Test #14:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

nine

output:

1
1

result:

ok 2 lines

Test #15:

score: 0
Accepted
time: 84ms
memory: 148892kb

input:

enfzncejemisgzoqnzkgtltxvxybvwddlpsndjyemdcbxyifzjygquvkvbmuhoblihvbxuthwryohdosidsfuzpzgixpkconlbpgscilqqvpblzmwuyrmvwngpnftlcmkjrjsdvgosnnbkldmrrkmucrqyulyxpqehztlssgpmcdsmzylvzaclzgvzaaajsfyyssmthmlaxmudbmmubwdtuifgryoxhorzhjvqxmjcqirlcmvfuttraqyjeztbilbvygakdhxzvyrqcddljjcgzcolvqljabluixyerpevtp...

output:

999618
2

result:

ok 2 lines

Test #16:

score: -100
Wrong Answer
time: 87ms
memory: 50076kb

input:

zerofoureightfourzerofourthreesixfiveonesixoneighteighthreefoursixzeroeighteightzeroneightsevenfourseveneightwoeightwosixninesevenseventwonineightonezerosixonesixsixsixzeroeightsixzerothreefoursevenfourfiveninefiveninetwofouronesevenseventhreesixfoursixfourninesixonesevenzerofourzeroninezeroseveneig...

output:

290113
7457277

result:

wrong answer 2nd lines differ - expected: '4873734', found: '7457277'