QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586925#8244. Digit TranslationAmy621TL 0ms3800kbC++141.4kb2024-09-24 16:34:422024-09-24 16:34:43

Judging History

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

  • [2024-09-24 16:34:43]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3800kb
  • [2024-09-24 16:34:42]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

map<string, char> digitMap = {
    {"zero", '0'}, {"one", '1'}, {"two", '2'}, {"three", '3'}, {"four", '4'},
    {"five", '5'}, {"six", '6'}, {"seven", '7'}, {"eight", '8'}, {"nine", '9'}
};

set<string> findMinStrings(string a) {
    set<string> results;
    bool replaced = false;
    

    for (auto &pair : digitMap) {
        string word = pair.first;
        size_t pos = a.find(word);
        if (pos != string::npos) {
            replaced = true;
            string newStr = a.substr(0, pos) + pair.second + a.substr(pos + word.size());
           
            set<string> subResults = findMinStrings(newStr);
            results.insert(subResults.begin(), subResults.end());
        }
    }

    // If no replacement was made, the current string is a final result
    if (!replaced) {
        results.insert(a);
    }

    return results;
}

int main() {
    string a;
    cin >> a;


    set<string> minStrings = findMinStrings(a);


    if (!minStrings.empty()) {
        cout << (*minStrings.begin()).size() << "\n";  
        cout << minStrings.size() << "\n";  
    } else {

        cout << a.size() << "\n";
        cout << 1 << "\n";  
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

icecreamcone

output:

10
1

result:

ok 2 lines

Test #2:

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

input:

onetwo

output:

2
1

result:

ok 2 lines

Test #3:

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

input:

twone

output:

3
2

result:

ok 2 lines

Test #4:

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

input:

a

output:

1
1

result:

ok 2 lines

Test #5:

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

input:

zero

output:

1
1

result:

ok 2 lines

Test #6:

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

input:

one

output:

1
1

result:

ok 2 lines

Test #7:

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

input:

two

output:

1
1

result:

ok 2 lines

Test #8:

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

input:

three

output:

1
1

result:

ok 2 lines

Test #9:

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

input:

four

output:

1
1

result:

ok 2 lines

Test #10:

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

input:

five

output:

1
1

result:

ok 2 lines

Test #11:

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

input:

six

output:

1
1

result:

ok 2 lines

Test #12:

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

input:

seven

output:

1
1

result:

ok 2 lines

Test #13:

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

input:

eight

output:

1
1

result:

ok 2 lines

Test #14:

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

input:

nine

output:

1
1

result:

ok 2 lines

Test #15:

score: -100
Time Limit Exceeded

input:

enfzncejemisgzoqnzkgtltxvxybvwddlpsndjyemdcbxyifzjygquvkvbmuhoblihvbxuthwryohdosidsfuzpzgixpkconlbpgscilqqvpblzmwuyrmvwngpnftlcmkjrjsdvgosnnbkldmrrkmucrqyulyxpqehztlssgpmcdsmzylvzaclzgvzaaajsfyyssmthmlaxmudbmmubwdtuifgryoxhorzhjvqxmjcqirlcmvfuttraqyjeztbilbvygakdhxzvyrqcddljjcgzcolvqljabluixyerpevtp...

output:


result: