QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758246#9557. Temperancelight_ink_dots#WA 1ms10072kbC++201.6kb2024-11-17 17:05:362024-11-17 17:05:43

Judging History

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

  • [2024-11-17 17:05:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10072kb
  • [2024-11-17 17:05:36]
  • 提交

answer

//Cut it out, you've already lost.
#include<bits/stdc++.h>
using namespace std;
const int maxn=500005;
int n,m,T,tot;
int a[maxn],b[maxn],c[maxn],ans[maxn],del[maxn];
map<int,int>mp[3];
map<int,vector<int>>ps[3];
priority_queue< pair<int,pair<int,int>> >q;
int main(){
	scanf("%d",&T);
	while(T--){
		mp[0].clear(),mp[1].clear(),mp[2].clear();
		ps[0].clear(),ps[1].clear(),ps[2].clear();
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d%d%d",&a[i],&b[i],&c[i]),del[i]=0;
			ps[0][a[i]].emplace_back(i);
			ps[1][b[i]].emplace_back(i);
			ps[2][c[i]].emplace_back(i);
			mp[0][a[i]]++,mp[1][b[i]]++,mp[2][c[i]]++;
		}
		for(int d=0;d<=2;d++)
			for(map<int,int>::iterator it=mp[d].begin();it!=mp[d].end();it++)
				q.push(make_pair(-(it->second),make_pair(d,it->first)));
		for(int i=0;i<=n;i++)
			ans[i]=n;
		tot=0;
		while(!q.empty()){
			int val=-q.top().first;
			int typ=q.top().second.first,id=q.top().second.second;
			q.pop();
			if(val<=0||mp[typ][id]!=val)
				continue;
//			printf("val=%d typ=%d id=%d\n",val,typ,id);
			if(val>0)
				ans[val-1]=min(ans[val-1],tot);
			for(int i=0;i<ps[typ][id].size();i++){
				int x=ps[typ][id][i];
				del[x]++;
				if(del[x]==3){
//					printf("delete x=%d\n",x);
					tot++;
					mp[0][a[x]]--,mp[1][b[x]]--,mp[2][c[x]]--;
					q.push(make_pair(-mp[0][a[x]],make_pair(0,a[x])));
					q.push(make_pair(-mp[1][b[x]],make_pair(1,b[x])));
					q.push(make_pair(-mp[2][c[x]],make_pair(2,c[x])));
				}
			}
		}
		for(int i=n-1;i>=0;i--)
			ans[i]=min(ans[i],ans[i+1]);
		for(int i=0;i<n;i++)
			printf("%d%c",ans[i],i==n-1? '\n':' ');
	}
	return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 1ms
memory: 10072kb

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 5 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 5 5
0 0 0 0 6 6
0 0 0 0 7 7 7
0 0 0 0 8 8 8 8

result:

wrong answer 14th numbers differ - expected: '1', found: '5'