QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#590497 | #8230. Submissions | ucup-team3519 | RE | 0ms | 0kb | C++20 | 4.5kb | 2024-09-26 01:03:39 | 2024-09-26 01:03:39 |
answer
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define all0(x) (x).begin(),(x).end()
#define all1(x) (x).begin()+1,(x).end()
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define cin std::cin
#define cout std::cout
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
//const int MN = 2e5 + 20;
const int INF = 2e9 + 1000;
const LL INFLL = 8e18 + 1000;
mt19937 mrand(chrono::steady_clock().now().time_since_epoch().count());
//模板区域~~~~~~~
//模板结束~~~~~~~
struct val {
int num, time;
};
bool operator<(val a, val b) {
if(a.num != b.num) return a.num > b.num;
return a.time < b.time;
}
val operator+(val a, val b) {
return {a.num + b.num, a.time + b.time};
}
val operator-(val a, val b) {
return {a.num - b.num, a.time - b.time};
}
void solve() {
int m; cin >> m;
int tot = 0;
map<string, int> id;
map<int, string> str;
V<int> ans(m + 1);
V<V<int>> panalty(26, V<int>(m + 1));
V<V<val>> normal_val(26, V<val>(m + 1));
V<V<val>> now_val(26, V<val>(m + 1));
V<val> sum_val(m + 1);
V<V<V<val>>> alt_val(26, V<V<val>>(m + 1));
V<V<int>> cnt_ac(26, V<int>(m + 1));
V<int> valid_team(m + 1);
int cnt_valid = 0;
V<int> teams;
V<int> solved_cnt(m + 1);
V<int> sp(m + 1);
for(int i = 1; i <= m; i++) {
string team; cin >> team;
int teamid;
if(!id.count(team)) id[team] = ++tot, str[tot] = team;
teamid = id[team];
teams.pb(teamid);
char c; int time; string stname;
cin >> c >> time >> stname;
c -= 'A';
int st;
if(stname == "accepted") st = 1;
else st = 0;
time += panalty[c][teamid];
if(st && cnt_ac[c][teamid] == 0) {
if(!valid_team[teamid]) {
cnt_valid++;
valid_team[teamid] = 1;
}
solved_cnt[teamid]++;
normal_val[c][teamid] = now_val[c][teamid] = {1, time};
sum_val[teamid] = sum_val[teamid] + normal_val[c][teamid];
}
if(cnt_ac[c][teamid] == 0 || cnt_ac[c][teamid] == 1 && st) {
alt_val[c][teamid].pb({1, time});
}
cnt_ac[c][teamid] += st;
panalty[c][teamid] += 20;
}
for(int i = 0; i < 26; i++) {
for(auto name : teams) {
if(cnt_ac[i][name] == 1) alt_val[i][name].pb({0, 0});
}
}
set<pair<val, int>> cur;
for(auto name : teams) {
cur.insert({sum_val[name], name});
}
int test = 0;
int cnt_cal_ans = 0;
auto cal_ans = [&]() -> void {
cnt_cal_ans++;
assert(cnt_cal_ans <= 4 * m);
int x = min(35, (cnt_valid + 9) / 10);
if(x == 0) return;
auto it = cur.begin();
for(int i = 1; i <= x; i++) {
ans[it->se] = 1;
it++;
}
if(test) {
if(!(prev(it)->fi < sum_val[test])) {
ans[test] = 1;
}
}
while(it != cur.end() && it->fi.num == prev(it)->fi.num && it->fi.time == prev(it)->fi.time) {
ans[it->se] = 1;
sp[it->se]++;
if(sp[it->se] >= 60) break;
it++;
}
};
cal_ans();
int cnt_chg = 0;
auto chg = [&](int name, int c, val v) -> void {
cnt_chg++;
assert(cnt_chg <= 4 * m);
cur.erase({sum_val[name], name});
val pv = now_val[c][name];
now_val[c][name] = v;
if(solved_cnt[name]) valid_team[name] = 0, cnt_valid--;
solved_cnt[name] -= pv.num;
solved_cnt[name] += v.num;
if(solved_cnt[name]) valid_team[name] = 1, cnt_valid++;
sum_val[name] = sum_val[name] - pv;
sum_val[name] = sum_val[name] + v;
cur.insert({sum_val[name], name});
test = name;
};
for(int i = 0; i < 26; i++) {
for(auto name : teams) {
if(alt_val[i][name].empty()) continue;
for(auto v : alt_val[i][name]) {
chg(name, i, v);
cal_ans();
}
chg(name, i, normal_val[i][name]);
}
}
cout << accumulate(all1(ans), 0LL) << endl;
for(int i = 1; i <= m; i++) {
if(ans[i]) cout << str[i] << " ";
}
cout << endl;
}
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
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...