QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775370#9557. TemperanceSkyzhouWA 1ms4400kbC++141.6kb2024-11-23 15:40:142024-11-23 15:40:15

Judging History

This is the latest submission verdict.

  • [2024-11-23 15:40:15]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 4400kb
  • [2024-11-23 15:40:14]
  • Submitted

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#define MAXN 100001
using namespace std;

struct node
{
	int x, y, z;
} s[MAXN];

int cnt[MAXN], ans[MAXN];

bool cmp1(node a, node b)
{
	return a.x < b.x;
}

bool cmp2(node a, node b)
{
	return a.y < b.y;
}

bool cmp3(node a, node b)
{
	return a.z < b.z;
}

int main()
{
	int T, n;
	cin >> T;
	while(T--)
	{
		memset(cnt, 0, sizeof(cnt));
		memset(ans, 0, sizeof(ans));
		cin >> n;
		for(int x = 0; x < n; x++) cin >> s[x].x >> s[x].y >> s[x].z;
		sort(s, s+n, cmp1);
		int sti = 0;
		for(int x = 0; x < n; x++)
		{
			if(x == 0) continue;
			if(s[x].x != s[x-1].x)
			{
				for(int y = sti; y < x; y++) cnt[y] = max(cnt[y], x-sti-1);
				sti = x;
			}
		}
		for(int y = sti; y < n; y++) cnt[y] = max(cnt[y], n-sti-1);
		sort(s, s+n, cmp2);
		sti = 0;
		for(int x = 0; x < n; x++)
		{
			if(x == 0) continue;
			if(s[x].y != s[x-1].y)
			{
				for(int y = sti; y < x; y++) cnt[y] = max(cnt[y], x-sti-1);
				sti = x;
			}
		}
		for(int y = sti; y < n; y++) cnt[y] = max(cnt[y], n-sti-1);
		sort(s, s+n, cmp3);
		sti = 0;
		for(int x = 0; x < n; x++)
		{
			if(x == 0) continue;
			if(s[x].z != s[x-1].z)
			{
				for(int y = sti; y < x; y++) cnt[y] = max(cnt[y], x-sti-1);
				sti = x;
			}
		}
		for(int y = sti; y < n; y++) cnt[y] = max(cnt[y], n-sti-1);
		
		sort(cnt, cnt+n);
		
//		for(int x = 0; x < n; x++) cout << cnt[x] << " ";
//		cout << endl;
		
		for(int x = 0; x < n; x++) ans[cnt[x]]++;
		int tmp = 0;
		for(int x = 0; x < n; x++)
		{
			cout << tmp << " ";
			tmp += ans[x];
		}
		cout << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4376kb

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

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

result:

wrong answer 13th numbers differ - expected: '0', found: '1'