首页 > 代码库 > HDU 4891

HDU 4891

一道简单的模拟题

需要要匹配{} 和 $$ 符里面的东西即可

//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler#include <stdio.h>#include <iostream>#include <cstring>#include <cmath>#include <stack>#include <queue>#include <vector>#include <algorithm>#define ll long long#define Max(a,b) (((a) > (b)) ? (a) : (b))#define Min(a,b) (((a) < (b)) ? (a) : (b))#define Abs(x) (((x) > 0) ? (x) : (-(x)))using namespace std;const int INF = 0x3f3f3f3f;char a[3000000];ll flag1, flag2;ll flag1_num, flag2_num;ll ans;bool ff;void init(){    flag1 = flag2 = 0;    flag1_num = flag2_num = ans = 1;    ff = false;}int main(){    ll i, j, k, t, m, n;    while(cin >> n){        getchar();        init();        for(k = 0; k < n; ++k){            gets(a);            ll len = strlen(a);            for(i = 0; i < len; ++i){                if(a[i] == {){                    flag1 = 1;                } else if(a[i] == }){                    flag1 = 0;                    ans *= flag1_num;                    flag1_num = 1;                } else if(a[i] == $ && !flag2){                    flag2 = 1;                } else if(a[i] == $ && flag2){                    flag2 = 0;                } else if(a[i] == | && flag1){                    ++flag1_num;                } else if(a[i] ==   && flag2){                    ++flag2_num;                } else{                    flag2_num = 1;                }                if(a[i] ==   && a[i + 1] !=   && flag2){                    ans *= flag2_num;                    flag2_num = 1;                }                if(ans > 100000)    ff = true;            }        }        if(ff){            printf("doge\n");        }        else{            cout << ans << endl;        }    }    return 0;}

 

HDU 4891