标签:count() pac tar reset ble its cstring 题解 wap
题目:http://hihocoder.com/problemset/problem/1513
自带的题解写得很好……
#include<cstdio> #include<cstring> #include<algorithm> #include<bitset> using namespace std; int rdn() { int ret=0;bool fx=1;char ch=getchar(); while(ch>‘9‘||ch<‘0‘){if(ch==‘-‘)fx=0;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘)ret=ret*10+ch-‘0‘,ch=getchar(); return fx?ret:-ret; } const int N=3e4+5; int n,rk[5][N],dy[5][N]; bitset<N> b[2][N]; int main() { n=rdn(); for(int i=1,d;i<=n;i++) for(int j=0;j<5;j++) { d=rdn(); rk[j][i]=d; dy[j][d]=i; } for(int i=1;i<=n;i++)b[0][i].set(); int u=1,v=0; for(int j=0;j<5;j++,swap(u,v)) { int lst=dy[j][1]; for(int i=2;i<=n;i++) { int cr=dy[j][i]; b[u][cr]=b[u][lst]; b[u][cr][lst]=1; lst=cr; } for(int i=1;i<=n;i++) b[u][i]&=b[v][i], b[v][i].reset(); } for(int i=1;i<=n;i++)printf("%d\n",b[v][i].count()); return 0; }
标签:count() pac tar reset ble its cstring 题解 wap
原文地址:https://www.cnblogs.com/Narh/p/10386184.html