結果

問題 No.2240 WAC
ユーザー 👑 kmjpkmjp
提出日時 2023-03-10 23:58:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,295 bytes
コンパイル時間 4,296 ms
コンパイル使用メモリ 209,228 KB
実行使用メモリ 22,504 KB
最終ジャッジ日時 2023-10-18 09:18:22
合計ジャッジ時間 6,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 137 ms
22,504 KB
testcase_11 AC 153 ms
22,504 KB
testcase_12 AC 130 ms
22,504 KB
testcase_13 AC 31 ms
10,028 KB
testcase_14 AC 13 ms
6,480 KB
testcase_15 AC 65 ms
16,132 KB
testcase_16 AC 83 ms
18,140 KB
testcase_17 AC 53 ms
13,728 KB
testcase_18 AC 22 ms
7,460 KB
testcase_19 AC 27 ms
8,500 KB
testcase_20 AC 70 ms
17,148 KB
testcase_21 AC 43 ms
11,088 KB
testcase_22 AC 40 ms
12,088 KB
testcase_23 AC 32 ms
10,044 KB
testcase_24 AC 73 ms
15,940 KB
testcase_25 AC 70 ms
15,512 KB
testcase_26 AC 25 ms
8,752 KB
testcase_27 AC 19 ms
7,308 KB
testcase_28 AC 31 ms
9,440 KB
testcase_29 AC 10 ms
5,708 KB
testcase_30 AC 44 ms
12,124 KB
testcase_31 AC 85 ms
20,008 KB
testcase_32 AC 21 ms
7,132 KB
testcase_33 AC 47 ms
12,920 KB
testcase_34 AC 57 ms
14,820 KB
testcase_35 AC 8 ms
5,260 KB
testcase_36 AC 74 ms
16,096 KB
testcase_37 AC 79 ms
18,544 KB
testcase_38 AC 34 ms
9,572 KB
testcase_39 AC 96 ms
20,656 KB
testcase_40 AC 43 ms
12,144 KB
testcase_41 AC 59 ms
15,136 KB
testcase_42 AC 60 ms
14,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
string S;
set<int> W,A,C;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S;
	
	FOR(i,S.size()) {
		if(S[i]=='W') W.insert(i);
		if(S[i]=='A') A.insert(i);
		if(S[i]=='C') C.insert(i);
	}
	while(W.size()) {
		x=*W.rbegin();
		W.erase(x);
		y=*A.rbegin();
		A.erase(y);
		if(x>y) {
			cout<<"No"<<endl;
			return;
		}
	}
	while(A.size()) {
		x=*A.begin();
		A.erase(x);
		y=*C.begin();
		C.erase(y);
		if(x>y) {
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0