結果

問題 No.265 数学のテスト
ユーザー snteasntea
提出日時 2015-09-22 23:56:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,756 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 77,912 KB
実行使用メモリ 6,392 KB
最終ジャッジ日時 2023-09-26 14:31:29
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,392 KB
testcase_01 AC 4 ms
5,020 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 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,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <utility>

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

typedef pair<int,int> P;
typedef long long int LL;

int N,d;
string S;

vector<int> form(int& i);
vector<int> dform(int& i);
vector<int> pform(int& i);
vector<int> mform(int& i);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	cin>>d;
	d++;
	cin>>S;
	int i=0;
	vector<int> res=pform(i);
	//cout<<i<<endl;
	REP(i,SZ(res))	cout<<res[i]<<' ';
	cout<<endl;
	return 0;
}

vector<int> form(int& i)
{
	vector<int> res(d,0);
	if(S[i]!='d'){
		return pform(i);
	}else{
		return dform(i);
	}
}

vector<int> pform(int& i)
{
	//cout<<'p'<<i<<endl;
	vector<int> res(d,0);
	while(true){
		vector<int> tmp;
		if(S[i]!='d')	tmp=mform(i);
		else	tmp=dform(i);
		REP(j,d){
			res[j]+=tmp[j];
		}
		if(S[i]!='+'){
			return res;
		}
		i++;
		if(i>=N)	return res;
	}
}

vector<int> dform(int& i)
{
	//cout<<'d'<<i<<endl;
	i+=2;
	vector<int> res=pform(i);
	REP(j,d-1){
		res[j]=(res[j+1])*(j+1);
		res[j+1]=0;
	}
	i++;
	return res;
}

vector<int> mform(int& i)
{
	//cout<<'m'<<i<<endl;
	vector<int> res(d,0);
	int m=1;
	if(S[i]!='x'){
		m=S[i]-'0';
		i+=2;
	}
	int c=1;
	i++;
	while(S[i]=='*'){
		c++;
		i++;
		if(S[i]!='x'){
			m=S[i]-'0';
			i+=2;
		}
		i++;
	}
	//DEBUG(c);
	res[c]+=m;
	return res;
}
0