QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769263#9557. TemperanceAiriS#WA 0ms12768kbC++142.2kb2024-11-21 16:50:542024-11-21 16:50:55

Judging History

This is the latest submission verdict.

  • [2024-11-21 16:50:55]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 12768kb
  • [2024-11-21 16:50:54]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>void read(T &x){
    x=0;char c=getchar();bool f=false;
    while(c<'0'||c>'9'){if(c=='-')f=true;c=getchar();}
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    if(f) x=-x;
}
const int N=100003;
int T;
int n;
int a[N][3],c[N][3];
bool v[N];
vector<int> poi[N][3];
struct Node{
    int k,p,c;
    bool operator <(const Node &A)const{
        if(c!=A.c) return c<A.c;
        if(k!=A.k) return k<A.k;
        return p<A.p;
    }
};
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            v[i]=false;
        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++){
                scanf("%d",&a[i][j]);
                c[a[i][j]][j]=0;
                poi[a[i][j]][j].clear();
            }
        }
        for(int i=1;i<=n;i++)
            for(int j=0;j<3;j++)
                poi[a[i][j]][j].push_back(i);
        for(int i=1;i<=n;i++)
            for(int j=0;j<3;j++)
                c[a[i][j]][j]++;
        vector<Node> s;
        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++){
                s.push_back((Node){j,a[i][j],c[a[i][j]][j]});
            }
        }
        sort(s.begin(),s.end());
        int ans=0;
        for(int i=0,now=0;i<n;i++){
            while(now<s.size()){
                if(s[now].c>=i+1) break;
                int p=s[now].p,k=s[now].k;
                for(auto x:poi[p][k]){
                    if(!v[x]){
                        bool flag=true;
                        for(int j=0;j<3;j++){
                            if(c[a[x][j]][j]>c[p][k]){
                                flag=false;
                                break;
                            }
                        }
                        if(!flag) continue;
                        ans++;
                        v[x]=true;
                        for(int j=0;j<3;j++){
                            c[a[x][j]][j]--;
                        }
                    }
                }
                now++;
            }
            printf("%d ",ans);
        }
        puts("");
    }
    return 0;
}

详细

Test #1:

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

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

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 4 4 
0 0 0 0 3 3 3 
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 4 4 
0 0 0 0 3 3 3 
0 0 0 0 8 8 8 8 

result:

wrong answer 20th numbers differ - expected: '6', found: '4'