HDU 4891 The Great Pan
模拟题。
#include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<functional> using namespace std; #define ms(x,y) memset(x,y,sizeof(x)) #define rep(i,j,k) for(int i=j;i<=k;i++) #define per(i,j,k) for(int i=j;i>=k;i--) #define loop(i,j,k) for (int i=j;i!=-1;i=k[i]) #define inone(x) scanf("%d",&x) #define intwo(x,y) scanf("%d%d",&x,&y) #define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z) #define infou(x,y,z,p) scanf("%d%d%d%d",&x,&y,&z,&p) #define lson x<<1,l,mid #define rson x<<1|1,mid+1,r #define mp(i,j) make_pair(i,j) #define ft first #define sd second typedef long long LL; typedef pair<int, int> pii; const int low(int x) { return x&-x; } const int INF = 0x7FFFFFFF; const int mod = 1e9 + 7; const int N = 4e5 + 10; const double eps = 1e-10; int n; char t[5000010]; int p1,p2,ans; int f; void G() { for(int i=0;t[i];i++) { if(t[i]!=' ') { if(f==1) { if(1LL*(p1+1)*ans<=100000) ans=(p1+1)*ans; else ans=100001; } p1=0; } if(t[i]=='{') p2=0; else if(t[i]=='}') { if(1LL*(p2+1)*ans<=100000) ans=(p2+1)*ans; else ans=100001; } else if(t[i]=='|') p2++; else if(t[i]==' ') p1++; else if(t[i]=='$') { f=f^1; } } } int main() { while(~scanf("%d",&n)) { getchar(); ans=1; f=p1=p2=0; while(n--) { gets(t); G(); } if(ans>100000) printf("doge\n"); else printf("%d\n",ans); } return 0; }