QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#649204#8230. SubmissionsxiaozhiRE 55ms8460kbC++203.8kb2024-10-17 22:04:302024-10-17 22:04:31

Judging History

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

  • [2024-10-17 22:04:31]
  • 评测
  • 测评结果:RE
  • 用时:55ms
  • 内存:8460kb
  • [2024-10-17 22:04:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int N = 1e5 + 2;
const int M = 26;

bool cmp(array<int, 2> &x, array<int, 2> &y) {
  if (x[0] != y[0]) return x[0] > y[0];
  return x[1] <= y[1];
}

vector<array<int, 2>> rnk;
vector<array<int, 2>> g[N][M];
string na[N];
map<string, int> id;
set<int> ans;

array<int, 2> check(int x) {
  array<int, 2> p1;
  p1[0] = p1[1] = 0;
  for (int j = 0; j < M; j++) {
    if (g[x][j].empty()) continue;
    int fi = -1;
    for (int k = 0; k < g[x][j].size(); k++) {
      if (g[x][j][k][1] == 1) {
        fi = k;
        break;
      }
    }
    if (fi != -1) {
      p1[0]++;
      p1[1] += fi * 20 + g[x][j][fi][0];
    }
  }
  return p1;
}

void solve() {
  int m;
  cin >> m;
  int n = 0;
  rnk.clear();
  for (int i = 1; i <= m; i++) {
    string c, s;
    char p;
    int t;
    cin >> c >> p >> t >> s;
    if (id.find(c) == id.end()) {
      ++n;
      na[n - 1] = c;
      id[c] = n;
    }
    g[id[c] - 1][p - 'A'].push_back({t, s == "accepted"});
  }

  int h = 0;
  for (int i = 0; i < n; i++) {
    array<int, 2> p1 = check(i);
    rnk.push_back(p1);
    h += (p1[0] != 0);
  }
  sort(rnk.begin(), rnk.end(), cmp);

  int last = min((h + 9) / 10, 35), q;

  for (int i = 0; i < n; i++) {
    array<int, 2> p1 = check(i);
    for (int j = 0; j < M; j++) {
      if (g[i][j].empty()) continue;
      int fi = -1, se = -1;
      for (int k = 0; k < g[i][j].size(); k++) {
        if (g[i][j][k][1] == 1) {
          if (fi == -1) {
            fi = k;
          } else {
            se = k;
            break;
          }
        }
      }

      if (fi == -1) {
        h += (p1[0] == 0);
        p1[0]++;
        p1[1] += g[i][j][0][0];

        q = min((h + 9) / 10, 35);
        if (q == 0 || cmp(p1, rnk[q - 1])) ans.insert(i);

        p1[0]--;
        p1[1] -= g[i][j][0][0];
        h -= (p1[0] == 0);
      } else {
        p1[1] -= (20 * fi + g[i][j][fi][0] - g[i][j][0][0]);

        q = min((h + 9) / 10, 35);
        if (q > 0 && q - 1 < n && cmp(p1, rnk[q - 1])) ans.insert(i);

        p1[1] += (20 * fi + g[i][j][fi][0] - g[i][j][0][0]);
      }

      if (fi == -1 && p1[0] == 0) {
        h++;
        p1[0]++;
        p1[1] += (g[i][j].size() - 1) * 20 + g[i][j].back()[0];

        q = min((h + 9) / 10, 35);
        if (q > 0 && q - 1 < n && cmp(rnk[q - 1], p1)) last = max(last, q);

        p1[0]--;
        p1[1] -= ((g[i][j].size() - 1) * 20 + g[i][j].back()[0]);
        h--;
      }

      q = min((h + 9) / 10, 35);
      if (fi == -1 || q == 0 || !cmp(p1, rnk[q - 1])) continue;

      if (se == -1) {
        p1[0]--;
        p1[1] -= (20 * fi + g[i][j][fi][0]);
        h -= (p1[0] == 0);

        q = min((h + 9) / 10, 35);
        if (q >= 0 && q < n && cmp(rnk[q], p1)) last = max(last, q + 1);

        h += (p1[0] == 0);
        p1[0]++;
        p1[1] += (20 * fi + g[i][j][fi][0]);
      } else {
        p1[1] += (20 * (se - fi) + g[i][j][se][0] - g[i][j][fi][0]);

        q = min((h + 9) / 10, 35);
        if (q >= 0 && q < n && cmp(rnk[q], p1)) last = max(last, q + 1);

        p1[1] -= (20 * (se - fi) + g[i][j][se][0] - g[i][j][fi][0]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    array<int, 2> p1 = check(i);
    if (last > 0 && last - 1 < n && cmp(p1, rnk[last - 1])) ans.insert(i);
  }

  cout << ans.size() << "\n";
  for (auto ppp : ans) cout << na[ppp] << " ";
  cout << "\n";

  rnk.clear();
  ans.clear();
  id.clear();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < M; j++) g[i][j].clear();
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 8336kb

input:

2
5
TSxingxing10 G 0 rejected
TSxingxing10 B 83 accepted
aoliaoligeiliao J 98 accepted
TS1 J 118 accepted
TS1 B 263 accepted
12
AllWayTheNorth A 0 rejected
YaoYaoLingXian Y 10 accepted
XuejunXinyoudui1 X 200 rejected
XuejunXinyoudui1 X 200 accepted
LetItRot L 215 accepted
AllWayTheNorth W 250 accept...

output:

2
TSxingxing10 TS1 
4
AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan 

result:

ok 2 test cases ok. (2 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 6820kb

input:

2
2
jiangly_fan A 1 accepted
jiangly B 23 accepted
3
conqueror_of_tourist A 1 accepted
conqueror_of_tourist A 2 accepted
tourist B 23 accepted

output:

2
jiangly_fan jiangly 
1
conqueror_of_tourist 

result:

ok 2 test cases ok. (2 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 8008kb

input:

2
13
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 rejected
12
A A 1 accepted
A X 1 accepted
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 a...

output:

11
A K B C D E F G H I J 
1
A 

result:

ok 2 test cases ok. (2 test cases)

Test #4:

score: 0
Accepted
time: 3ms
memory: 6856kb

input:

2
11
A A 1 accepted
B B 1 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 accepted
12
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 a...

output:

2
A B 
2
A K 

result:

ok 2 test cases ok. (2 test cases)

Test #5:

score: 0
Accepted
time: 55ms
memory: 8460kb

input:

100000
1
M3JytWoaEXxkACy_mBAQ R 111 accepted
1
sQ O 151 accepted
1
JinbrcS58gNEE5yTSkT B 140 accepted
1
cklwBY V 243 accepted
1
v_o42YmvEKFwy Q 260 rejected
1
ftQVK8S_um22w K 265 accepted
1
_bQBeFeDpYQhvZcLf9l3 Z 147 accepted
1
KvDcEAIDN A 75 rejected
1
H3MUK6 A 101 rejected
1
gxYo_oCFn2J8aIben U 54...

output:

1
M3JytWoaEXxkACy_mBAQ 
1
sQ 
1
JinbrcS58gNEE5yTSkT 
1
cklwBY 
1
v_o42YmvEKFwy 
1
ftQVK8S_um22w 
1
_bQBeFeDpYQhvZcLf9l3 
1
KvDcEAIDN 
1
H3MUK6 
1
gxYo_oCFn2J8aIben 
1
_isnlUGK0ddI 
1
BERcVjyCp 
1
6In2do_50ylch 
1
f0r3SXc6brMjT 
1
7njYOapSwvogA 
1
x 
1
y1w3KvxylfxwprRBYw 
1
aGedzS 
1
iPo0GDhIF 
1
4Vf...

result:

ok 100000 test cases ok. (100000 test cases)

Test #6:

score: -100
Runtime Error

input:

10000
42
Bzs0PiQMXGZ5rRZ_2D G 2 accepted
9XtB_VIfbRRL E 11 accepted
FVJL M 13 rejected
a S 19 accepted
tsd Z 20 rejected
MyCqVEg1ONjZ U 22 accepted
6SgZMn N 51 rejected
Qua1Pti3vKhyQKDUm P 54 accepted
i29 M 63 accepted
zPqu D 68 rejected
xx2yiu6x C 71 rejected
fYuK1KNkuyO5HRCq L 76 rejected
tXWpYVqj...

output:


result: