結果

問題 No.265 数学のテスト
ユーザー Lepton_sLepton_s
提出日時 2015-08-07 22:48:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,541 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 79,292 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-25 06:08:57
合計ジャッジ時間 3,846 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

int n, d;
string s;

void expr(int l, int r, vector<int>& a);
void term(int l, int r, vector<int>& a);

void expr(int l, int r, vector<int>& a){
	int p = 0;
	for(int i = l; i <= r; i++){
		if(i==r || (p==0 && s[i]=='+')){
			vector<int> a2(d+1, 0);
			term(l, i, a2);
			l = i+1;
			for(int j = 0; j <= d; j++) a[j] += a2[j];
		}
		if(i==r) return;
		if(s[i]=='{') p++;
		if(s[i]=='}') p--;
	}
}

void term(int l, int r, vector<int>& a){
	for(int i = l; i < r; i+=2){
		if(s[i]=='d') continue;
		if(i==l) break;
		int t = (i-l)/2;
		vector<int> a2(d+1, 0);
		expr(i, r-t, a2);
		for(int j = 0; j < t; j++){
			for(int k = 1; k <= d; k++)
				a2[k-1] = k*a2[k];
			a2[d] = 0;
		}
		for(int j = 0; j <= d; j++) a[j] += a2[j];
		return;
	}
	int cnst = 1, deg = 0;
	for(int i = l; i < r; i+=2){
		if(s[i]=='x') deg++;
		else cnst *= s[i]-'0';
	}
	a[deg] += cnst;
}

int main(){
	cin>>n>>d>>s;
	vector<int> a(d+1, 0);
	expr(0, n, a);
	for(int i = 0; i <= d; i++) printf("%d%c",a[i],i==d?'\n':' ');
	return 0;
}
0