結果

問題 No.805 UMG
ユーザー ohreitetsuohreitetsu
提出日時 2019-03-22 22:03:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 647 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-29 10:36:51
合計ジャッジ時間 4,640 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 33 ms
5,376 KB
testcase_16 AC 28 ms
5,376 KB
testcase_17 AC 17 ms
5,376 KB
testcase_18 AC 48 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 46 ms
5,376 KB
testcase_21 AC 21 ms
5,376 KB
testcase_22 AC 29 ms
5,376 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	string S;
	cin>>S;
	int i,j,k,num=0;
	int Unum=0,Mnum=0,Gnum=0;
	for (i=0;i<N;i++){
		switch(S[i]){
			case 'U':
				Unum=1;
				break;
			case 'M':
				Mnum=1;
				break;
			case 'G':
				Gnum=1;
				break;
		}
		if (Unum+Mnum+Gnum==3){
			break;
		}
	}
	if (Unum+Mnum+Gnum<3){
		cout<<0<<endl;
		return 0;
	}
	for (i=1;i<=N-2;i++){
		for (j=i+1;j<=N-1;j++){
			for (k=j+1;k<=N;k++){
				if (2*j==i+k){
					if (S[i-1]=='U' &&S[j-1]=='M' &&S[k-1]=='G'){
						num++;
					}
					break;
				}
			}
		}
	}
	cout<<num<<endl;
	return 0;
}
0