标签:*** tar 空间 tac ase main struct ret back
https://hihocoder.com/problemset/problem/1513
五维偏序问题,直接bitset压位,复杂度O(n^2/32)
(本来想写三维偏序,但是cdq不会只好写写五维bitset暴力这样子,三维那题bitset空间也开不下= =)
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define cd complex<double>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
const double g=10.0,eps=1e-12;
const int N=30000+10,maxn=1000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;
struct node{
int a[5],id;
}s[N];
bitset<N>b[N][5],ans;
int now;
bool cmp(node x,node y)
{
return x.a[now]<y.a[now];
}
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=0;j<5;j++)
scanf("%d",&s[i].a[j]);
s[i].id=i;
}
for(int i=0;i<5;i++)
{
now=i;
sort(s,s+n,cmp);
for(int j=1;j<n;j++)
{
b[s[j].id][i]=b[s[j-1].id][i];
b[s[j].id][i].set(s[j-1].id);
}
}
for(int i=0;i<n;i++)
{
ans=b[i][0];
for(int j=1;j<5;j++)ans&=b[i][j];
printf("%d\n",ans.count());
}
return 0;
}
/***********************
***********************/
标签:*** tar 空间 tac ase main struct ret back
原文地址:https://www.cnblogs.com/acjiumeng/p/9260823.html