結果

問題 No.457 (^^*)
ユーザー tabataba
提出日時 2017-05-18 07:16:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 990 ms / 2,000 ms
コード長 1,312 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 77,172 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 22:28:16
合計ジャッジ時間 4,263 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 13 ms
4,348 KB
testcase_10 AC 143 ms
4,348 KB
testcase_11 AC 990 ms
4,348 KB
testcase_12 AC 470 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 633 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <random>
#include <vector>
#include <algorithm>
#include <array>
#include <functional>
#include <utility>

using namespace std;
int main(){
	char s[10001];
	-scanf("%s",s);
	int end=0,count[]={0,0};
	while(s[end])end++;
	vector<int> startpos,yama,aste,endpos;
	for(int i=0;i<end;i++){
		if(s[i]=='(')
			startpos.push_back(i);
		if(s[i]=='^')
			yama.push_back(i);
		if(s[i]=='*')
			aste.push_back(i);
		if(s[i]==')')
			endpos.push_back(i);
	}
	for(int a:startpos){
		for(auto e=upper_bound(endpos.begin(),endpos.end(),a);e<endpos.end();e++){
			bool flag=true;
			//left ^^*
			for(auto y1=upper_bound(yama.begin(),yama.end(),a);y1<yama.end()&&*y1<*e&&flag;y1++){
				for(auto y2=upper_bound(y1,yama.end(),*y1);y2<yama.end()&&*y2<*e&&flag;y2++){
					if(any_of(aste.begin(),aste.end(),[e,y2](int x){return *y2<x&&x<*e;})){
						flag=false;
					}
				}
			}
			flag||count[0]++;
			flag=true;
			//right *^^
			for(auto as=upper_bound(aste.begin(),aste.end(),a);as<aste.end()&&*as<*e&&flag;as++){
				for(auto y1=upper_bound(yama.begin(),yama.end(),*as);y1<yama.end()&&*y1<*e&&flag;y1++){
					if(any_of(y1+1,yama.end(),[e](int x){return x<*e;})){
						flag=false;
					}
				}
			}
			flag||count[1]++;
		}
	}
	printf("%d %d\n",count[0],count[1]);
	return 0;
}
0