QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631679#516. Roman Holidayschuchu#WA 1ms3680kbC++201.8kb2024-10-12 09:37:012024-10-12 09:37:02

Judging History

This is the latest submission verdict.

  • [2024-10-12 09:37:02]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3680kb
  • [2024-10-12 09:37:01]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

vector<string>all;

map<ll, string>f;
map<char, ll>sz;

string get(ll x) {
    string ans = "";
    if(x>=100) ans += f[(x/100)*100];
    x %= 100;
    if(x>=10)  ans += f[(x/10)*10];
    x %= 10;
    if(x) ans += f[x]; 
    return ans;
}

void init() {
    f[1] = "I";
    f[2] = "II";
    f[3] = "III";
    f[4] = "IV";
    f[5] = "V";
    f[6] = "VI";
    f[7] = "VII";
    f[8] = "VIII";
    f[9] = "IX";
    
    f[10] = "X";
    f[20] = "XX";
    f[30] = "XXX";
    f[40] = "XL";
    f[50] = "L";
    f[60] = "LX";
    f[70] = "LXX";
    f[80] = "LXXX";
    f[90] = "XC";
    
    f[100] = "C";
    f[200] = "CC";
    f[300] = "CCC";
    f[400] = "CD";
    f[500] = "D";
    f[600] = "DC";
    f[700] = "DCC";
    f[800] = "DCCC";
    f[900] = "CM";

    for(ll i = 1 ; i <= 999 ;i ++) {
        all.push_back(get(i));
        //cout << i << ' ' << get(i) << endl;
    }
    sort(begin(all), end(all));
    for(auto &s: all) {
        sz[s[0]]++;
    }
}


void solve() {
    ll n; cin >> n;
    while(n--) {
        ll x; cin >> x;
        ll cnt = x/1000;
        x %= 1000;
        
        if(x==0) {
            cout << cnt * (sz['C'] + sz['D'] + sz['I'] + sz['L'] + 1) << '\n'; 
            continue;
        }

        ll now = 0;
        string temp = get(x);
        if(temp[0]=='C' or temp[0]=='D') {
            now = cnt*(sz['C'] + sz['D'] + sz['I'] + sz['L'] + 1);
            now += lower_bound(begin(all), end(all), temp) - begin(all) + 1;
        }
        else {
            now = -cnt*(sz['V'] + sz['X']);
            now -= end(all) - lower_bound(begin(all), end(all), temp);
        }
        cout << now << '\n';
    }
}

int main() {
    init();
    solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3680kb

input:

100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

output:

-99
-98
-97
-96
-54
-53
-52
-51
-95
-50
-39
-38
-37
-36
-24
-23
-22
-21
-35
-20
-19
-18
-17
-16
-14
-13
-12
-11
-15
-10
-9
-8
-7
-6
-4
-3
-2
-1
-5
-34
-33
-32
-31
-30
-28
-27
-26
-25
-29
-94
-93
-92
-91
-90
-88
-87
-86
-85
-89
-84
-83
-82
-81
-80
-78
-77
-76
-75
-79
-74
-73
-72
-71
-70
-68
-67
-66
-...

result:

wrong answer 1st lines differ - expected: '901', found: '-99'