QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727877 | #9557. Temperance | ucup-team3161# | WA | 3ms | 13240kb | C++17 | 1.2kb | 2024-11-09 14:02:42 | 2024-11-09 14:02:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define tiii tuple<int,int,int>
#define eb emplace_back
const int N=1e5+5;
int T,n,ans,w1[N],a[N][3],w[N][3];bool vs[N][3];
vector<int> vc[N][3];
priority_queue<tiii,vector<tiii>,greater<tiii>> q;
void del(int x)
{
++ans;
for(int i=0;i<3;++i)
q.push({--w[a[x][i]][i],a[x][i],i});
}
void slv()
{
scanf("%d",&n);
for(int i=1;i<=n;++i) for(int j=0;j<3;++j)
scanf("%d",&a[i][j]);
for(int i=1;i<=n;++i) for(int j=0;j<3;++j)
vs[a[i][j]][j]=w[a[i][j]][j]=0,vc[a[i][j]][j].clear();
for(int i=1;i<=n;++i) for(int j=0;j<3;++j)
++w[a[i][j]][j],vc[a[i][j]][j].eb(i);
for(int i=1;i<=n;++i) for(int j=0;j<3;++j)
q.push({w[a[i][j]][j],a[i][j],j});
for(int i=1;i<=n;++i) w1[i]=3;
ans=0;
for(int i=0;i<n;++i)
{
while(!q.empty() && get<0>(q.top())<=i)
{
auto [w,x,y]=q.top();q.pop();
if(vs[x][y]) continue;
vs[x][y]=1;
for(auto j:vc[x][y]) {--w1[j];if(!w1[j]) del(j);}
}
printf("%d ",ans);
}
puts("");
}
int main()
{
scanf("%d",&T);
while(T--) slv();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 12516kb
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: 3ms
memory: 13240kb
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 2 0 0 3 0 0 0 4 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 2 0 0 3 0 0 0 4 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:
wrong answer 3rd numbers differ - expected: '0', found: '2'