QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752664#9557. Temperanceucup-team4938#WA 79ms12792kbC++141.4kb2024-11-16 09:07:252024-11-16 09:07:31

Judging History

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

  • [2024-11-16 09:07:31]
  • 评测
  • 测评结果:WA
  • 用时:79ms
  • 内存:12792kb
  • [2024-11-16 09:07:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n, a[3][100010], f[3][100010];
bool bk[100010], b[3][100010];
vector<int> c[3][100010];
struct Node{
	int id, tp, x;
	bool operator <(const Node u) const{ return x > u.x; }
};
priority_queue<Node> q;
int calc(int x){ return max(max(f[0][a[0][x]], f[1][a[1][x]]), f[2][a[2][x]]); }
void del(int x){
	int i, j;
	for(i = 0; i < 3; i++){
		j = a[i][x];
		f[i][j]--;
		q.push({j, i, f[i][j]});
	}
}
void solve(){
	int i, j, p, u, v, res = 0;
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		scanf("%d%d%d", &a[0][i], &a[1][i], &a[2][i]);
		f[0][a[0][i]]++; f[1][a[1][i]]++; f[2][a[2][i]]++;
		c[0][a[0][i]].push_back(i); c[1][a[1][i]].push_back(i); c[2][a[2][i]].push_back(i);
		bk[i] = false;
	}
	for(i = 1; i <= n; i++){
		for(j = 0; j < 3; j++){
			p = a[j][i];
			q.push({p, j, f[j][p]});
		}
	}
	for(i = 0; i < n; i++){
		while(q.size() > 0){
			if(q.top().x > i) break;
			j = q.top().id; p = q.top().tp; q.pop();
			if(b[p][j]) continue;
			b[p][j] = true;
			for(u = 0; u < c[p][j].size(); u++){
				v = c[p][j][u];
				if(calc(v) <= i && !bk[v]) del(v), bk[v] = true, res++;
			}
		}
		printf("%d ", res);
	}
	printf("\n");
	for(i = 1; i <= n; i++){
		for(j = 0; j < 3; j++){
			c[j][a[j][i]].clear(); b[j][a[j][i]] = false; f[j][a[j][i]] = 0;
		}
	}
}
int main()
{
	int t;
	scanf("%d", &t);
	while(t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 12792kb

input:

2
5
1 1 1
1 1 2
1 1 3
2 3 5
2 2 4
3
1 1 1
2 2 2
3 3 3

output:

0 0 2 5 5 
0 3 3 

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 12048kb

input:

16
1
1 1 1
2
1 1 1
1 1 100000
3
1 1 1
1 1 100000
1 100000 1
4
1 1 1
1 1 100000
1 100000 1
1 100000 100000
5
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
6
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
100000 1 100000
7
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
100000 ...

output:

0 
0 0 
0 0 0 
0 0 0 0 
0 0 0 1 5 
0 0 0 0 6 6 
0 0 0 0 7 7 7 
0 0 0 0 8 8 8 8 
0 
0 0 
0 0 0 
0 0 0 0 
0 0 0 1 5 
0 0 0 0 6 6 
0 0 0 0 7 7 7 
0 0 0 0 8 8 8 8 

result:

ok 72 numbers

Test #3:

score: -100
Wrong Answer
time: 79ms
memory: 12284kb

input:

10000
22
1 4 4
7 2 6
6 5 4
4 4 1
1 7 1
7 6 6
5 8 6
4 4 8
6 7 6
1 7 3
5 7 8
5 1 3
2 1 7
1 2 5
6 1 2
3 1 1
7 3 8
1 4 6
6 5 7
4 4 7
7 7 5
3 4 6
13
2 7 3
2 7 5
5 1 5
8 7 1
6 6 7
3 5 8
8 1 6
4 8 4
1 4 3
6 2 5
6 8 4
1 5 5
5 3 4
28
4 7 2
3 8 5
1 1 6
1 7 4
5 5 6
6 1 5
4 5 2
1 1 5
2 6 3
4 3 6
4 5 7
3 3 6
6 8...

output:

0 0 0 0 7 12 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 
0 0 3 9 13 13 13 13 13 13 13 13 13 
0 0 0 0 8 21 21 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 
0 0 1 9 9 14 14 14 14 14 14 14 14 14 
0 0 0 6 9 12 12 19 19 19 19 19 19 19 19 19 19 19 19 
0 0 0 0 3 8 10 22 36 36 36 36 3...

result:

wrong answer 1349th numbers differ - expected: '5', found: '3'