QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623349#8048. Roman MasterConsW#WA 50ms3612kbC++202.7kb2024-10-09 11:27:402024-10-09 11:28:04

Judging History

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

  • [2024-10-09 11:28:04]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:3612kb
  • [2024-10-09 11:27:40]
  • 提交

answer

#include<bits/stdc++.h>

#define i64 long long
#define u64 unsigned long long
#define ll long long

using namespace std;

typedef pair<i64, i64> pii;

const i64 MOD = 1e9 + 7;
const u64 P = 131;

inline i64 lowbit(i64 x) { return x & (-x); }

inline i64 highbit(i64 x) {
    i64 cnt = 0;
    do {
        if (x == 1) return 1LL << cnt;
        else ++cnt;
    } while (x >>= 1);
}

inline i64 factory(i64 start, i64 end) {
    if (start > end) return 0;
    i64 cnt = 1;
    while (start <= end) {
        cnt *= start++;
        cnt %= MOD;
    }
    return cnt;
}//阶乘(含模运算),从start乘到end

inline i64 gcd(i64 a, i64 b) {
    while (b ^= a ^= b ^= a %= b);
    return a;
}//最小公约数

inline bool isPrime(i64 x) {
    for (int i = 2; i <= sqrt(x); ++i) {
        if (x % i == 0) return false;
    }
    if (x != 1) return true;
    else return false;
}

inline bool cmp(pii a, pii b) {
    return a.first > b.first;
}

inline i64 query(i64 a, i64 b) {
    i64 tmp;
    cout << "? " << a << " " << b << endl;
    cin >> tmp;
    return tmp;
}

inline i64 to_i64(string s) {
    stringstream ss(s);
    i64 tmp;
    ss >> tmp;
    return tmp;
}//字符串转long long

inline i64 LIS(i64 arr[], i64 n) {
    i64 dp[n], len = 0;
    dp[0] = arr[0];
    for (int i = 1; i < n; ++i) {
        if (arr[i] > dp[len]) dp[++len] = arr[i];
        else *(lower_bound(dp, dp + len, arr[i])) = arr[i];
    }
    return len + 1;
}

inline i64 qpow(i64 a, i64 n) {
    i64 res = 1;
    while (n) {
        if (n & 1) res *= a;
        a *= a;
        a %= MOD;
        n >>= 1;
        res %= MOD;
    }
    return res;
}

void solve() {
    string s;
    cin >> s;
    string res;
    i64 cnt = 0, cnti = 0, i = s.size() - 1;
    while (i >= 0) {
        if (cnti == 4) {
            cnti = 0;
            res = '3' + res;
            cnt = 0;
            i++;
        }
        if (s[i] == 'V') {
            if (cnti == 0 && i > 0 && s[i - 1] == 'I') {
                res = '4' + res;
                cnt = 0;
                cnti = 0;
                i -= 2;
            } else {
                cnt += 5;
                res = (char) (cnt + '0') + res;
                cnt = 0;
                cnti = 0;
                i--;
            }
        }
        if (s[i] == 'I') {
            cnt++;
            cnti++;
            i--;
        }
    }
    if (cnt == 4) res = "13" + res;
    if (cnt != 0) res = (char) (cnt + '0') + res;
    cout << res << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
II
IVI
VIIIIIV

output:

2
16
634

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 50ms
memory: 3552kb

input:

100000
VVIVVVVVII
VVVIIIIVVI
IVIIVIIIIV
VVVVVIIVVI
IIIVIVVVIV
VIVIIIIIVI
VVIIVVIVVI
IVVVIVVVVV
VIIVVVVIVV
VIIIIVVVVV
VVVVVVIVIV
VIVIIIVVVI
VIIIVIVVVI
VIIIIVVIIV
VIVVVIIVII
IIIIIVIIVI
IIIIVVVVII
IVIIVVIIVI
IVVIVVIIIV
IVVVIIIVIV
IIIIVIIIVV
VVVVVIVIIV
VVVIIIIVVV
VIVVIIIIVI
VIIIIIIIIV
VIVIVVVIVV
IVIIIVI...

output:

5545557
55846
1784
5555646
244554
6736
564546
45545555
6455545
845555
55555544
67456
74456
8464
54577
2376
34557
16476
45474
45744
413745
5555664
558455
54636
6334
5445545
1863
27645
34645
54746
55556455
46345
3746
74546
6633
5455544
738
4776
8666
1455445
555555556
44444
456445
5733
488
5455544
6336...

result:

wrong answer 21st lines differ - expected: '13745', found: '413745'