做网站商城需要多少钱,免费网页托管,美团网站网站建设发展,全屏企业网站欣赏CF1223F. Stack Exterminable Arrays
Solution
奇怪的套路增加了。
大概就是[l,r][l,r][l,r]能匹配完可以转化为[1,l−1][1,l-1][1,l−1]匹配后的状态和[1,r][1,r][1,r]匹配后的状态相同#xff0c;因此hashhashhash判断即可。
Code
#include vector
#include 因此hashhashhash判断即可。
Code
#include vector
#include list
#include map
#include set
#include deque
#include queue
#include stack
#include bitset
#include algorithm
#include functional
#include numeric
#include utility
#include sstream
#include iostream
#include iomanip
#include cstdio
#include cmath
#include cstdlib
#include cctype
#include string
#include cstring
#include ctime
#include cassert
#include string.h
//#include unordered_set
//#include unordered_map
//#include bits/stdc.h#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i(a);i(b);i)
#define fi first
#define se secondusing namespace std;templatetypename Tinline bool upmin(T x,T y) { return yx?xy,1:0; }
templatetypename Tinline bool upmax(T x,T y) { return xy?xy,1:0; }typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pairint,int PR;
typedef vectorint VI;const lod eps1e-11;
const lod piacos(-1);
const int oo130;
const ll loo1ll62;
const int mods1e99;
const int MAXN1000005;
const int INF0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{int f1,x0; char cgetchar();while (c0||c9) { if (c-) f-1; cgetchar(); }while (c0c9) { x(x3)(x1)(c^48); cgetchar(); }return x*f;
}
ull h[MAXN];
mapull,int Map;
int a[MAXN],f[MAXN],stk[MAXN],SZ1e97;
signed main()
{int Caseread();while (Case--){ll ans0;int nread(),top0;for (int i1;in;i) a[i]read(),f[i]0;Map.clear(),Map[0]n1,f[n1]0;for (int in;i1;i--){if (topstk[top]a[i]) top--;else stk[top]a[i],h[top]h[top-1]*SZa[i];if (Map[h[top]]) f[i]f[Map[h[top]]]1;Map[h[top]]i;ansf[i];}printf(%lld\n,ans);}return 0;
}