QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739776#9544. Grand Prix of BallanceNoT1m3Cons1d3rWA 1ms3812kbC++202.4kb2024-11-12 23:03:302024-11-12 23:03:34

Judging History

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

  • [2024-11-12 23:03:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3812kb
  • [2024-11-12 23:03:30]
  • 提交

answer

#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
using namespace std;
#define il inline
#define rr read()
#define wr puts()
#define bl putchar(' ')
#define in int
#define max(x, y) (x > y ? x : y)
#define min(x, y) (x < y ? x : y)
#define rep(i, l, n) for (in i = l; i >= n; i--)
#define int long long
il int read()
{
    char ch;
    bool f = 0;
    while ((ch = getchar()) < '0' || ch > '9')
        (ch == '-') && (f = 1);
    in x = ch ^ '0';
    while ((ch = getchar()) <= '9' && ch >= '0')
        x = (x << 1) + (x << 3) + (ch ^ '0');
    return f ? -x : x;
}

il void print(in x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x >= 10)
        print(x / 10);
    putchar(x % 10 ^ '0');
}

const int MAXN = 4e6 + 100;

struct node
{
    int index, point;
};

bool cmp(node a, node b)
{
    if (a.point != b.point)
        return a.point > b.point;
    else
        return a.index < b.index;
}

void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<node> participant(m);
    vector<int> vis(m);
    int temp = 0;
    queue<int> complete;
    for (int i = 0; i < m; ++i)
        participant[i].index = i + 1;
    while (q--)
    {
        int op;
        cin >> op;
        if (op == 1)
        {
            int mp;
            cin >> mp;
            temp = mp;
            for (int i = 0; i < m; ++i)
                vis[i] = 0;
            while (!complete.empty())
                complete.pop();
            continue;
        }
        int id, x;
        cin >> id >> x;
        id--;
        if (op == 3)
        {
            vis[id] = -1;
        }
        if (op == 2)
        {
            if (x != temp)
                continue;
            if (vis[id] != 0)
                continue;
            vis[id] = 1;
            complete.emplace(id);
            participant[id].point += m - complete.size() + 1;
        }
    }
    sort(participant.begin(), participant.end(), cmp);
    for (int i = 0; i < m; ++i)
    {
        cout << participant[i].index << " " << participant[i].point << "\n";
    }
    return;
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int t;
    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: 3588kb

input:

3
3 4 6
1 2
2 1 1
2 2 2
3 3 2
2 3 2
2 1 2
3 4 8
1 2
2 1 1
2 2 2
3 3 2
2 3 2
2 1 2
1 1
2 1 1
3 4 7
1 2
2 1 1
2 2 2
3 3 2
2 3 2
2 1 2
1 1

output:

2 4
1 3
3 0
4 0
1 7
2 4
3 0
4 0
2 4
1 3
3 0
4 0

result:

ok 12 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3812kb

input:

10
18 8 8
2 1 6
1 13
2 1 18
3 8 13
2 7 14
2 5 11
3 6 13
3 1 13
26 7 11
1 22
2 7 22
1 9
2 6 24
1 2
1 18
3 3 4
2 3 18
1 26
3 7 1
3 2 26
1 3 33
3 3 1
2 3 1
2 2 1
1 1
2 1 1
2 1 1
3 1 1
3 3 1
3 2 1
3 3 1
2 2 1
2 2 1
3 3 1
2 2 1
2 2 1
3 3 1
2 3 1
2 3 1
3 3 1
2 3 1
2 2 1
2 2 1
2 2 1
2 1 1
3 2 1
2 2 1
3 2 1...

output:

1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
7 7
1 0
2 0
3 0
4 0
5 0
6 0
1 3
2 0
3 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
25 25
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
1 0
2 0
...

result:

wrong answer 9th lines differ - expected: '3 7', found: '7 7'