QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788282#9557. Temperancefrankly6#WA 33ms3728kbC++171.5kb2024-11-27 16:25:082024-11-27 16:26:19

Judging History

This is the latest submission verdict.

  • [2024-11-27 16:26:19]
  • Judged
  • Verdict: WA
  • Time: 33ms
  • Memory: 3728kb
  • [2024-11-27 16:25:08]
  • Submitted

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int MX=100010;

int T, N;
int nx[MX], ny[MX], nz[MX];
int ans[MX];
int read()
{
    int r=0, f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
    return r*f;
}
struct pl
{
    int x, y, z;
    bool operator < (const pl &a)const
    {
        return max(nx[x],max(ny[y],nz[z])) > max(nx[a.x],max(ny[a.y],nz[a.z]));
    }
};
priority_queue<pl> q;
int main()
{
    // freopen("testdata.in","r",stdin);
    T=read();
    while(T--)
    {
        N=read();
        for(int i=1;i<=N;i++)
        {
            int x=read(), y=read(), z=read();
            nx[x]++, ny[y]++, nz[z]++;
            q.push({x,y,z});
        }
        int num=0;
        for(int i=1;i<=N+1;i++)
        {
            while(!q.empty())
            {
                auto [x,y,z] = q.top();
                int den=max(nx[x],max(ny[y],nz[z]));
                // cout << "x=" << x << ", y=" << y << ", z=" << z << ", den=" << den << '\n';
                if(den<i) 
                {
                    num++;
                    nx[x]--; ny[y]--; nz[z]--;
                    q.pop();
                }
                else break;
            }
            if(i!=N+1) cout << num << " ";
        }
        cout << '\n';
    }
    return (0-0);
}

詳細信息

Test #1:

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

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: 0ms
memory: 3728kb

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: 33ms
memory: 3704kb

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 0 0 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 
0 0 0 9 13 13 13 13 13 13 13 13 13 
0 0 0 0 4 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 6 6 14 14 14 14 14 14 14 14 14 
0 0 0 4 7 12 12 19 19 19 19 19 19 19 19 19 19 19 19 
0 0 0 0 1 6 6 18 36 36 36 36 36 ...

result:

wrong answer 5th numbers differ - expected: '7', found: '0'