QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875523#9544. Grand Prix of Ballancewarner1129#WA 5ms52944kbC++201.7kb2025-01-29 22:14:092025-01-29 22:14:09

Judging History

This is the latest submission verdict.

  • [2025-01-29 22:14:09]
  • Judged
  • Verdict: WA
  • Time: 5ms
  • Memory: 52944kb
  • [2025-01-29 22:14:09]
  • Submitted

answer

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

#define ll long long
#define ld long double
#define endl '\n'

#define MOD 998244353
#define MXN 500'500

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
int randint(int lb, int ub)
{ return uniform_int_distribution<int>(lb, ub)(gen); }


ll n, m, q;
ll arr[MXN];
bool isActive[MXN];
set<int> isCompleted[MXN], isGiveup[MXN];
ll score[MXN];

void solve() {
	cin >> n >> m >> q;

	fill(isActive, isActive+n+1, 0);
	for(int i = 0; i <= n; i++){
		isCompleted[i].clear();
		isGiveup[i].clear();
	}
	for(int i = 0; i <= m; i++)
		score[i] = 0;
	
	while(q--){
		int op, x, y; cin >> op;
		if(op == 1){
			int x; cin >> x;
			isActive[x] = 1;
		}
		else if(op == 2){
			cin >> x >> y;
			if(!isActive[y] || isGiveup[y].count(x) || isCompleted[y].count(x))	continue;
			score[x] += m - isCompleted[y].size();
			isCompleted[y].insert(x);
		}
		else if(op == 3){
			cin >> x >> y;
			if(!isActive[y] || isGiveup[y].count(x) || isCompleted[y].count(x))	continue;
			isGiveup[y].insert(x);
		}
	}

	vector<int> ord(m);
	iota(ord.begin(), ord.end(), 1);
	sort(ord.begin(), ord.end(), [&](const int lhs, const int rhs){
		if(score[lhs] != score[rhs])
			return score[lhs] > score[rhs];
		return lhs < rhs;
	});
	for(int i = 0; i < m; i++)
		cout << ord[i] << " " << score[ord[i]] << endl;
	
}

signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int T = 1;
	cin >> T;
	for(int cas = 1; cas <= T; cas++){
		// cout << "Case #" << cas << ": ";
		solve();
	}
	return 0;
}
/*


*/

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 52820kb

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: 2ms
memory: 52944kb

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
3 7
7 7
1 0
2 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
22 25
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
23 0
24 0
1 0
2 0...

result:

wrong answer 43rd lines differ - expected: '25 25', found: '22 25'