結果

問題 No.2240 WAC
ユーザー ttkkggww
提出日時 2023-03-10 21:51:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 3,931 ms
コンパイル使用メモリ 254,988 KB
最終ジャッジ日時 2025-02-11 08:12:04
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
string s;

ll n,m;

void solve(){
	set<int> W,A,C;
	for(int i = 0;i<s.size();i++){
		if(s[i]=='W'){
			W.insert(i);
		}else if(s[i]=='A'){
			A.insert(i);
		}else{
			C.insert(i);
		}
	}
	for(auto &i:C){
		auto it = A.begin();
		if(i<(*it)){
			cout<<"No"<<endl;
			return;
		}
		A.erase(it);
	}
	for(auto &i:W){
		auto it = A.begin();
		if((*it)<i){
			cout<<"No"<<endl;
			return;
		}
		A.erase(it);
	}
	cout<<"Yes"<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	cin >> s;
	solve();
}
0