ICPC2015国内予選参加記

ICPCにチーム名「-D_GLIBCXX_DEBUG」として参加しました。
4完16位(ITF大学内2位)でした。


メンバーは @ichigo_o_re、@n_vip、@shiryobukaiです。
メンバーを探さずにだらだらしていたら@n_vipくんと@shiryobukaiくんにお誘いしていただきました。


A→@n_vip
B→@shiryobukai
C→@ichigo_o_re

くらいを40分くらいで解いてこの時点では大学内1位だったんですが、
そこから追いぬかれました。

その後@shiryobukaiと @n_vip くんがゴニョゴニョして通していて
自分はその間ずっと E を取り組んでいました。
解けませんでした。
@n_vipくんがDを通してくれました。

その後@shiryobukaiくんがFを書いている途中で3時間経過しました。

予選前まではだいぶヤバい感じだったんですけど、
予選ではすごくチームっぽい感じだったので良かったです。


Cのソースはくコ:彡です。
queueじゃなくてstackなのは内緒。

#include<bits/stdc++.h>

using namespace std;

#define rep(X,Y) for(int (X) = 0; (X) < (Y) ; (X)++)
#define reps(X,Y,Z) for(int (X) = (Y); (X) <= (Z) ; (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define eb emplace_back
#define X first
#define Y second

typedef pair<int,int> pii;

int main(){
	while(1){
		int N;
		int depth = 0;
		queue<int> num[120];
		queue<char> op[128];
		cin >> N;
		if(N == 0)break;
		rep(i,N){
			string str;
			cin >> str;
			int de = 0;
			rep(j,str.size()){
				if(str[j] == '.') de++;
				else if(str[j] == '*') op[de].push('*');
				else if(str[j] == '+') op[de].push('+');
				else num[de].push(str[j]-'0');
			}
			if( depth <= de ) depth = de;
			else if(depth > de){
				while( depth > de){
					int sum = num[depth].front();num[depth].pop();
					char oo = op[depth-1].front();op[depth-1].pop();
					while(!num[depth].empty()){
						if(oo == '*') sum *= num[depth].front();
						if(oo == '+') sum += num[depth].front();
						num[depth].pop();
					}
					num[depth-1].push(sum);
					depth--;
				}
			}
		}
		if(depth > 0){
			while( depth > 0){
				int sum = num[depth].front();num[depth].pop();
				char oo = op[depth-1].front();op[depth-1].pop();
				while(!num[depth].empty()){
					if(oo == '*') sum *= num[depth].front();
					if(oo == '+') sum += num[depth].front();
					num[depth].pop();
				}
				num[depth-1].push(sum);
				depth--;
			}
		}
		
		cout << num[0].front() << endl;
	}
	return 0;
}