QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#752556 | #9557. Temperance | ucup-team1004# | WA | 2ms | 8112kb | C++20 | 2.0kb | 2024-11-16 08:17:20 | 2024-11-16 08:17:20 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e5+5,M=N*4+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,A[N][3];
vector<int> S[3][N];
int vis[N],f[3][N];
void Solve(){
scanf("%d",&n);
vector<int> ns[3];
for(int i=1;i<=n;i++){
vis[i]=3;
for(int o:{0,1,2}){
scanf("%d",&A[i][o]),f[o][A[i][o]]++,S[o][A[i][o]].push_back(i);
ns[o].push_back(A[i][o]);
}
}
priority_queue<tuple<int,int,int> > q;
for(int o:{0,1,2}){
sort(all(ns[o]));
ns[o].erase(unique(all(ns[o])),ns[o].end());
for(int i:ns[o]) q.emplace(-f[o][i],i,o);
}
int cnt=0;
auto ers=[&](int x,int o){
f[o][A[x][o]]--;
q.emplace(-f[o][A[x][o]],A[x][o],o);
};
for(int i=1;i<=n;i++){
while(!q.empty()){
auto [w,a,b]=q.top();w*=-1;
if(w>=i) break;
q.pop();
for(int j:S[b][a]) if(!--vis[j]){
cnt++;
for(int o:{0,1,2}) ers(j,o);
}
}
printf("%d%c",cnt," \n"[i==n]);
}
for(int o:{0,1,2}) for(int j:ns[o]) S[o][j].clear(),f[o][j]=0;
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 7984kb
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: 1ms
memory: 8112kb
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 5 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 5 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 14th numbers differ - expected: '1', found: '5'