QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769011#9557. TemperanceAiriS#WA 0ms12768kbC++142.7kb2024-11-21 15:43:162024-11-21 15:43:16

Judging History

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

  • [2024-11-21 15:43:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:12768kb
  • [2024-11-21 15:43:16]
  • 提交

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]++;
        set<Node> s;
        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++){
                s.insert((Node){j,a[i][j],c[a[i][j]][j]});
            }
        }
        int ans=0;
        for(int i=0;i<n;i++){
            while(!s.empty()){
                auto it=s.begin();
                if(it->c==0){
                    s.erase(it);
                    continue;
                }
                if(it->c>=i+1) break;
                Node tmp=(*it);
                int p=it->p,k=it->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]--;
                            if(j!=k){
                                if(c[a[x][j]][j]+1>=i){
                                    s.erase((Node){j,a[x][j],c[a[x][j]][j]+1});
                                    s.insert((Node){j,a[x][j],c[a[x][j]][j]});
                                }
                            }
                        }
                    }
                }
                s.erase(tmp);
            }
            printf("%d ",ans);
        }
        puts("");
    }
    return 0;
}

详细

Test #1:

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

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

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'