QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623335 | #8048. Roman Master | ConsW# | WA | 37ms | 3808kb | C++20 | 2.7kb | 2024-10-09 11:24:31 | 2024-10-09 11:24:31 |
Judging History
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;
i -= 2;
} else {
cnt += 5;
res = (char) (cnt + '0') + res;
cnt = 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: 1ms
memory: 3768kb
input:
3 II IVI VIIIIIV
output:
2 16 634
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 37ms
memory: 3808kb
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:
5655557 557356 17384 5555756 244554 63836 5635656 45545555 6455545 845555 55555544 663556 736556 73564 655637 23376 335557 173576 156574 155744 33745 5555664 558455 65736 6334 5445545 16363 237645 235645 656356 55556455 156345 36356 735656 6633 5455544 7338 157376 83666 1455445 555555556 44444 15564...
result:
wrong answer 1st lines differ - expected: '5545557', found: '5655557'