码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 4891

时间:2014-11-04 19:25:45      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   os   for   sp   div   

一道简单的模拟题

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

//#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

标签:style   blog   io   color   ar   os   for   sp   div   

原文地址:http://www.cnblogs.com/wushuaiyi/p/4074068.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!