結果

問題 No.265 数学のテスト
コンテスト
ユーザー IL_msta
提出日時 2015-08-08 00:31:50
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 2,040 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 564 ms
コンパイル使用メモリ 112,036 KB
実行使用メモリ 119,880 KB
最終ジャッジ日時 2026-04-01 21:42:13
合計ジャッジ時間 4,781 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'std::vector<long long int> bbb(std::string, int)':
main.cpp:35:23: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 96 bytes into a region of size 88 overflows the destination [-Wstringop-overflow=]
   35 |                 ans[i]=0;
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:3:
In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = long long int]',
    inlined from 'static _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = long long int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/alloc_traits.h:614:28,
    inlined from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:387:33,
    inlined from 'void std::_Vector_base<_Tp, _Alloc>::_M_create_storage(std::size_t) [with _Tp = long long int; _Alloc = std::alloc

ソースコード

diff #
raw source code

#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