???hihoCoder???#1513 : ???Hi?????????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了???hihoCoder???#1513 : ???Hi?????????相关的知识,希望对你有一定的参考价值。
?????????algo name max string IV amp for ?????? long
??????
?????????????????????
????????????bitset???????????????
????????????rk[i][j]?????????j????????????i?????????
???30000 * 5????????????30000???bitset
s[i][j]?????????bitset?????????j???????????????1 - i???????????????
????????????????????????????????????????????????????????????and??????????????????count()??????????????????1?????????
??????
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <bitset>
#define enter putchar(???n???)
#define space putchar(??? ???)
//#define ivorysi
#define pb push_back
#define MAXN 30005
#define mo 974711
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < ???0??? || c > ???9???) {
if(c == ???-???) f = -1;
c = getchar();
}
while(c >= ???0??? && c <= ???9???) {
res = res * 10 - ???0??? + c;
c = getchar();
}
res = res * f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar(???-???);}
if(x >= 10) out(x / 10);
putchar(???0??? + x % 10);
}
int N;
bitset <MAXN> s[MAXN][6];
int a[MAXN][6],rk[MAXN][6];
void Solve() {
read(N);
for(int i = 1 ; i <= N ; ++i) {
for(int j = 1 ; j <= 5 ; ++j) {
read(a[i][j]);
rk[a[i][j]][j] = i;
}
}
for(int j = 1 ; j <= 5 ; ++j) {
for(int i = 1 ; i <= N ; ++i) {
s[i][j] = s[i - 1][j];
s[i][j][rk[i][j]] = 1;
}
}
for(int i = 1 ; i <= N ; ++i) {
bitset <MAXN> tmp;
tmp = s[a[i][1] - 1][1];
for(int j = 2 ; j <= 5 ; ++j) tmp &= s[a[i][j] - 1][j];
out(tmp.count());enter;
}
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}
以上是关于???hihoCoder???#1513 : ???Hi?????????的主要内容,如果未能解决你的问题,请参考以下文章
???hihoCoder???#1513 : ???Hi?????????
hihocoder#1513 : 小Hi的烦恼 bitset
hihocoder 1513 小Hi的烦恼 (bitset优化)