結果

問題 No.265 数学のテスト
ユーザー IL_mstaIL_msta
提出日時 2015-08-08 00:31:50
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 2,040 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 91,676 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 05:28:49
合計ジャッジ時間 5,401 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
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 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘std::vector<long long int> bbb(std::string, int)’:
main.cpp:36:24: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 96 bytes into a region of size 88 overflows the destination [-Wstringop-overflow=]
   36 |                 temp[i]=0;
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33,
                 from /usr/include/c++/11/bits/allocator.h:46,
                 from /usr/include/c++/11/string:41,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from main.cpp:3:
/usr/include/c++/11/ext/new_allocator.h:127:48: note: destination object of size 88 allocated by ‘operator new’
  127 |         return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
      |                                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

vector<LL> bbb(string s,int n){
	vector<LL> ans(11),temp(11);
	rep(i,12){
		ans[i]=0;
		temp[i]=0;
	}
	LL ter=0,X=0;
	for(int i = n;i<s.size();++i){
		if(s[i] == 'd'){
			temp = bbb(s,i+1);
			//}の位置がほしい
			i=temp[10];
			//*は無い
			for(int j=0;j<=10;++j){
				ans[j] = ans[j] + temp[j];
				temp[j] = 0;
			}
		}else if( s[i] =='+'){
			if(X>0){
				if( ter == 0){
					ans[X] = ans[X] + 1;
				}else{
					ans[X] = ans[X] + ter;
					ter = 0;
				}
				X = 0;
			}else{
				ans[0] = ans[0] + ter;
			}
			ter = 0;
		}else if( s[i] == 'x'){
			++X;
		}else if( s[i] == '*'){

		}else if( s[i] == '{'){

		}else if( s[i] == '}'){
			if(X>0){
				if( ter == 0){
					ans[X] = ans[X] + 1;
				}else{
					ans[X] = ans[X] + ter;
					ter = 0;
				}
				X = 0;
			}else{
				ans[0] = ans[0] + ter;
			}
			ter = 0;
			for(int j= 0;j<=10;++j){
				ans[j] = (j+1)*ans[j+1];
			}
			ans[11] = i;
			return ans;
		}else{
			if(ter != 0){
				ter = ter * (s[i] - '0');
			}else{
				ter = s[i] - '0';
			}
		}
	}
	if(X>0){
		if( ter == 0){
			ans[X] = ans[X] + 1;
		}else{
			ans[X] = ans[X] + ter;
			ter = 0;
		}
		X = 0;
	}else{
		ans[0] = ans[0] + ter;
	}
	ter = 0;
	return ans;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int N,d;
	string s;
	cin>>N>>d>>s;
	vector<LL> ans(11);
	ans = bbb(s,0);
	for(int i=0;i<=d;++i){
		cout << ans[i];
		if(i != d){
			cout << " ";
		}else{
			cout << endl;
		}
	}
	return 0;
}
0