QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#867123 | #9557. Temperance | piggy123# | WA | 1ms | 16372kb | C++17 | 4.0kb | 2025-01-23 09:32:05 | 2025-01-23 09:32:11 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct plt{
ll x,y,z;
}p[100005];
ll cntx[100005],cnty[100005],cntz[100005],vis[100005],ans[100005];
vector<ll> vctx[100005],vcty[100005],vctz[100005];
int main(){
cin.tie(0);cout.tie(0);
ios::sync_with_stdio(false);
ll t;
cin >> t;
while (t--){
ll n;
cin >> n;
vector<array<ll,3>> vv;
vector<array<ll,2>> book;
for (ll i=1;i<=n;i++){
cin >> p[i].x >> p[i].y >> p[i].z;
cntx[p[i].x]++;
cnty[p[i].y]++;
cntz[p[i].z]++;
vctx[p[i].x].push_back(i);
vcty[p[i].y].push_back(i);
vctz[p[i].z].push_back(i);
book.push_back({p[i].x,1});
book.push_back({p[i].y,2});
book.push_back({p[i].z,3});
vis[i]=0;
}
sort(book.begin(),book.end());
book.erase(unique(book.begin(),book.end()),book.end());
for (auto i:book){
if (i[1]==1){
vv.push_back({cntx[i[0]],i[0],1});
}else if (i[1]==2){
vv.push_back({cnty[i[0]],i[0],2});
}else if (i[1]==3){
vv.push_back({cntz[i[0]],i[0],3});
}
}
sort(vv.begin(),vv.end());
ll ps=vv.size(),c=0;
for (ll i=n-1;i>=0;i--){
while (ps-1>=0&&vv[ps-1][0]>=i+1){
if (vv[ps-1][2]==1){
for (ll j:vctx[vv[ps-1][1]]){
if (!vis[j])vis[j]=1,c++;
}
}else if (vv[ps-1][2]==2){
for (ll j:vcty[vv[ps-1][1]]){
if (!vis[j])vis[j]=1,c++;
}
}else{
for (ll j:vctz[vv[ps-1][1]]){
if (!vis[j])vis[j]=1,c++;
}
}
ps--;
}
ans[i]=n-c;
}
for (ll i=0;i<=n-1;i++)cout<< ans[i]<<" ";
cout<<"\b";
for (ll i=1;i<=n;i++){
cntx[p[i].x]=0;
cnty[p[i].y]=0;
cntz[p[i].z]=0;
vis[i]=0;
vctx[p[i].x].clear();
vcty[p[i].y].clear();
vctz[p[i].z].clear();
}
}
return 0;
}
/*
■■■■■ ■■ ■■■ ■■■ ■ ■ ■ ■■■■ ■■■■
■ ■■ ■■ ■ ■■ ■ ■■ ■ ■ ■■ ■ ■■ ■■ ■
■ ■ ■■ ■ ■ ■ ■ ■ ■ ■■■ ■■ ■■ ■ ■■
■ ■ ■■ ■ ■ ■ ■ ■ ■ ■■ ■ ■■ ■■
■ ■ ■■ ■ ■ ■■ ■■ ■■ ■
■ ■■ ■■ ■ ■■■ ■ ■■■ ■■ ■■ ■■ ■■■
■■■■■ ■■ ■ ■ ■ ■ ■■ ■■ ■■ ■■
■ ■■ ■ ■ ■ ■ ■■ ■■ ■■ ■
■ ■■ ■ ■ ■ ■ ■■ ■■ ■ ■ ■■
■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■ ■■ ■■
■ ■■ ■■■■ ■■■■ ■■ ■■ ■■■■■■ ■■■■
*/
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 16372kb
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 \x080 3 3 \x08
result:
wrong output format Expected integer, but "\x080" found