QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#869613 | #8613. Cardinality | ucup-team5008# | TL | 1ms | 3584kb | C++20 | 935b | 2025-01-25 12:01:42 | 2025-01-25 12:01:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep2(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define rep(i,j) rep2(i,0,j)
#define rrep2(i,j,k) for(ll i=ll(j)-1;i>=ll(k);i--)
#define rrep(i,j) rrep2(i,j,0)
#define SZ(a) ll(a.size())
#define all(a) a.begin(),a.end()
#define eb emplace_back
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using vp=vector<P>;
using vvp=vector<vp>;
const ll inf=LLONG_MAX/4;
template<typename T>
bool chmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T>
bool chmax(T& a,T b){return a<b?a=b,1:0;}
int main(){
cin.tie(0)->sync_with_stdio(0);
ll n,q;cin>>n>>q;
const ll div=4;
random_device rnd;
mt19937_64 mt(rnd());
vl p(n);
rep(i,n) p[i]=i;
shuffle(all(p),mt);
const ll M=5e4;
vector<bitset<M/div+1>> bit(n+q);
rep(i,n) bit[i].set(p[i]/div);
rep2(i,n,n+q){
ll x,y;cin>>x>>y;
x--,y--;
bit[i]=bit[x]|bit[y];
cout<<bit[i].count()*2<<"\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
4 5 1 2 2 3 5 6 6 7 4 7
output:
2 2 2 2 2
result:
ok
Test #2:
score: -100
Time Limit Exceeded
input:
10 100 9 2 9 10 5 1 6 6 13 14 3 4 3 8 8 4 16 5 14 2 8 13 14 9 6 17 15 11 24 7 24 20 1 26 14 27 6 18 14 14 15 11 14 25 8 11 7 30 3 11 12 3 6 19 29 36 30 9 38 6 2 28 12 40 33 25 20 42 17 30 23 1 34 41 41 36 7 18 39 45 32 4 30 21 46 26 12 39 42 42 46 48 31 54 16 37 42 4 27 34