QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722631#9544. Grand Prix of Ballancejiangzhihui#WA 0ms3656kbC++141.4kb2024-11-07 19:43:172024-11-07 19:43:19

Judging History

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

  • [2024-11-07 19:43:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-11-07 19:43:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std ;
void solve()
{
    int n , m , q ;
    cin >> n >> m >> q ;
    vector<int> one(n , 0) ;
    vector<int> vis(m , -1) ;
    vector<vector<int>> p(n) ;
    int cur = -1 ;
    vector<long long> ans(m) ;
    vector<int> id(m) ;
    iota(id.begin() , id.end() , 0) ;
    while(q --)
    {
        int op ;
        cin >> op ;
        if(op == 1)
        {
            int x ;
            cin >> x ;
            x -= 1 ;
            if(one[x] == 1)  continue ;
            one[x] = 1 ;
            cur = x ;
        }
        else if(op == 2)
        {
            int id , x ;
            cin >> id >> x ;
            id -= 1 , x -= 1 ;
            if(x != cur)  continue ;
            if(vis[id] == x)  continue ;
            vis[id] = x ;
            ans[id] += m - p[x].size() ;
            p[x].push_back(id) ;
        }
        else
        {
            int id , x ;
            cin >> id >> x ;
            id -= 1 , x -= 1 ;
            vis[id] = cur ;
        }
    }
    sort(id.begin() , id.end() , [&](int x , int y)
    {
        if(ans[x] == ans[y])  return x < y ;
        return ans[x] > ans[y] ;
    }) ;
    for(auto u : id)  cout << u + 1 << ' ' << ans[u] << '\n' ;
}
int main()
{
    std::ios::sync_with_stdio(false) , cin.tie(0) ;

    int T ;
    cin >> T ;
    while (T --)  solve() ;
    return 0 ;
}

详细

Test #1:

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

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: 3552kb

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'