[Offer收割]编程练习赛25 register

Ended

Participants:399

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-03 12:14:17

Lang:G++

Edit
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int M = 1000000007;
int n;
pair<string, string> a[N];
inline int value(char c) {
  if (c == 'I') { return 1; }
  if (c == 'V') { return 5; }
  if (c == 'X') { return 10; }
  if (c == 'L') { return 50; }
  if (c == 'C') { return 100; }
  if (c == 'D') { return 500; }
  if (c == 'M') { return 1000; }
  assert(false);
  return -1;
}
int toVal(const string &s) {
  int ret = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    int s1 = value(s[i]);
    if (i + 1 < (int)s.size()) {
      int s2 = value(s[i + 1]);
      if (s1 >= s2) {
        ret += s1;
      } else {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX