QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#324525#8230. Submissionsucup-team3113#WA 123ms3688kbC++206.5kb2024-02-10 20:36:532024-02-10 20:36:53

Judging History

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

  • [2024-05-20 23:50:57]
  • hack成功,自动添加数据
  • (/hack/623)
  • [2024-05-20 23:48:44]
  • hack成功,自动添加数据
  • (/hack/622)
  • [2024-02-10 20:36:53]
  • 评测
  • 测评结果:WA
  • 用时:123ms
  • 内存:3688kb
  • [2024-02-10 20:36:53]
  • 提交

answer

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

#define TRACE(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define _ << " _ " <<

template<class> struct is_container : false_type {};
template<class... Ts> struct is_container<vector<Ts...>> : true_type {};
template<class... Ts> struct is_container<map<Ts...>> : true_type {};
template<class... Ts> struct is_container<unordered_map<Ts...>> : true_type {};
template<class... Ts> struct is_container<set<Ts...>> : true_type {};
template<class... Ts> struct is_container<unordered_set<Ts...>> : true_type {};
template<class... Ts> struct is_container<multiset<Ts...>> : true_type {};
template<class... Ts> struct is_container<unordered_multiset<Ts...>> : true_type {};
template<class T, class U>
ostream& operator<<(ostream &o, pair<T, U> x) {
  return o << "(" << x.first << ", " << x.second << ")";
}
template<class T, class = typename enable_if<is_container<T>::value>::type>
ostream& operator<<(ostream &o, T x) {
  int f = 1;
  o << "{";
  for (auto y : x) {
    o << (f ? "" : ", ") << y;
    f = 0;
  }
  return o << "}";
}

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int NUM_P = 26;
int problem_to_i(char p) { return p - 'A'; }

struct Problem {
    vector<pii> accepted, rejected;
    int penalty;
};

typedef vector<Problem> Team;

struct Submission {
    string c;
    char p;
    int t;
    string s;
};

template<class T>
int count_smaller(const vector<T>& vec, const T& el) {
    return lower_bound(all(vec), el) - vec.begin();
}

int ceil(int a, int b) {
    return (a + b - 1) / b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int m;
        cin >> m;
        vector<Submission> subs(m);
        map<string, Team> teams;
        for (int i = 0; i < m; i++) {
            auto& sub = subs[i];
            cin >> sub.c >> sub.p >> sub.t >> sub.s;

            if (!teams.count(sub.c)) teams[sub.c] = Team(NUM_P);
            auto& team = teams[sub.c];

            if (sub.s[0] == 'a') {
                team[problem_to_i(sub.p)].accepted.push_back({i, sub.t});
            } else {
                team[problem_to_i(sub.p)].rejected.push_back({i, sub.t});
            }
        }

        int teams_that_solved = 0; 
        map<string, pii> scores;
        for (auto& [name, team] : teams) {
            int problems = 0, penalty = 0;
            for (auto& problem : team) {
                if (problem.accepted.empty()) continue;
                problems++;
                int cnt = count_smaller(problem.rejected, problem.accepted[0]);
                problem.penalty = cnt * 20 + problem.accepted[0].se;
                penalty += problem.penalty;
            }
            scores[name] = {-problems, penalty};
            if (problems) teams_that_solved++;
        }

        set<pair<pii, string>> scoreboard;
        for (auto& [name, score] : scores) scoreboard.insert({score, name});

        //TRACE(scoreboard);

        auto candidates = scoreboard;
        set<string> sol;
        for (int i = -1; i < m; i++) {
            pii old_score, new_score;
            if (i != -1) {
                auto& sub = subs[i];
                old_score = scores[sub.c];

                new_score = old_score;
                auto& problem = teams[sub.c][problem_to_i(sub.p)];

                if (sub.s[0] == 'a') {  // accept -> reject
                    if (problem.accepted.size() >= 2) {  // there's another AC
                        if (problem.accepted[0].fi == i) {
                            new_score.se += 20;
                            new_score.se -= sub.t;
                            new_score.se += problem.accepted[1].se;
                        }
                    } else {  // this was the only AC
                        new_score.fi++;  // confusing because it's -problems
                        new_score.se -= problem.penalty;
                    }
                } else { // reject -> accept
                    if (problem.accepted.empty()) {  // wasn't solved previously
                        new_score.fi--;  // confusing because it's -problems
                        new_score.se += count_smaller(problem.rejected, {i, sub.t}) * 20;
                        new_score.se += sub.t;
                    } else {
                        if (i < problem.accepted[0].fi) {  // this AC is earlier
                            new_score.se -= problem.penalty;
                            new_score.se += count_smaller(problem.rejected, {i, sub.t}) * 20;
                            new_score.se += sub.t;
                        }
                    }
                }

                teams_that_solved -= !!old_score.fi;
                teams_that_solved += !!new_score.fi;

                scoreboard.erase({old_score, sub.c});
                scoreboard.insert({new_score, sub.c});
                if (!sol.count(sub.c)) {
                    candidates.erase({old_score, sub.c});
                    candidates.insert({new_score, sub.c});
                }
            }

            int gold_score_position = min({
                    ceil(teams_that_solved, 10), 
                    35, 
                    (int)scoreboard.size()
                }) - 1;
            auto gold_score_it = scoreboard.begin();
            advance(gold_score_it, gold_score_position);
            pii gold_score = gold_score_it->fi;
            //TRACE(gold_score_position _ gold_score _ scoreboard);

            while (!candidates.empty() && candidates.begin()->fi <= gold_score) {
                sol.insert(candidates.begin()->se);
                candidates.erase(candidates.begin());
            }

            if (i != -1) {
                auto& sub = subs[i];

                teams_that_solved -= !!new_score.fi;
                teams_that_solved += !!old_score.fi;

                scoreboard.erase({new_score, sub.c});
                scoreboard.insert({old_score, sub.c});
                if (!sol.count(sub.c)) {
                    candidates.erase({new_score, sub.c});
                    candidates.insert({old_score, sub.c});
                }
            }
        }

        cout << sol.size() << '\n';
        for (auto& s : sol) cout << s << ' ';
        cout << '\n';
    }

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
TS1 TSxingxing10 
4
AllWayTheNorth ImYourFan LetItRot XuejunXinyoudui1 

result:

ok 2 test cases ok. (2 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

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 jiangly_fan 
1
conqueror_of_tourist 

result:

ok 2 test cases ok. (2 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3624kb

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 B C D E F G H I J K 
1
A 

result:

ok 2 test cases ok. (2 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3648kb

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: 74ms
memory: 3560kb

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
Wrong Answer
time: 123ms
memory: 3688kb

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:

4
Qua1Pti3vKhyQKDUm fYuK1KNkuyO5HRCq tsd xiLm0TUOF3T 
2
JP t3 
2
77sgqpbTIr_Zt1 fhYPGC8W82NwJTQL 
2
3BQ pVWDEz 
2
buCeoOotAkV8DaFD6 tg 
1
UkXQ3iaNJ 
2
ALTqPt7JUSLrl vwfw 
1
QTEzV6tp 
3
4e1l0pO8eFjZwkDo 9cy_y_RNRwex8j7224hz wJlbqIU 
2
6mbCu5zA eiuF7a_ 
1
xy6QBr8ECi 
3
PezeyUurYoz7N1iGU _Yej1PrINtydmO...

result:

wrong answer the numbers are different in the case 27. (test case 27)