結果

問題 No.265 数学のテスト
ユーザー ishizuishizu
提出日時 2015-09-05 03:12:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,404 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 71,500 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-26 08:36:18
合計ジャッジ時間 2,083 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,384 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>

#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;cin>>N;
	int d;cin>>d;
	string s;cin>>s;
	int n=s.size();
	int nest=0;
	ll val;
	ll cr[d+1];fill(cr,cr+d+1,0);
	ll imp[10];imp[0]=1;
	REP(i,10-1){ imp[i+1] = imp[i]*(i+1);}

	REP(i,n){
		if(s[i]=='{') nest++;
		else if(s[i]=='}') nest--;
		else if('1'<=s[i] && s[i]<='9'){
			val=s[i]-'0';
			i+=2;
			int cnt=(i<n && s[i]=='x')? 1:0;
			while(i+1<n && s[i]=='x'&& s[i+1]=='*') i+=2,cnt++;
// 			DEBUG(cnt);DEBUG(nest);

			if(cnt-nest<0) continue;
			cr[cnt-nest] += 1LL*val* imp[cnt]/imp[cnt-nest];
		}
		else if(s[i]=='x'){
			val=1;
			int cnt=1;
			while(i+1<n && s[i]=='x' && s[i+1]=='*') i+=2,cnt++;
// 			DEBUG(cnt);DEBUG(nest);
			if(cnt-nest<0) continue;
			cr[cnt-nest] +=1LL* val* imp[cnt]/imp[cnt-nest];
		}
		
	}
	REP(i,d+1) cout<<cr[i]<<( (i==d)? "":" " );
	cout<<endl;
	 
}
0