結果

問題 No.2240 WAC
ユーザー hikaririhikariri
提出日時 2023-03-27 18:07:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 2,134 bytes
コンパイル時間 4,271 ms
コンパイル使用メモリ 235,580 KB
実行使用メモリ 22,680 KB
最終ジャッジ日時 2023-10-19 17:16:40
合計ジャッジ時間 7,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 133 ms
22,680 KB
testcase_11 AC 144 ms
22,680 KB
testcase_12 AC 138 ms
22,680 KB
testcase_13 AC 34 ms
10,144 KB
testcase_14 AC 16 ms
6,592 KB
testcase_15 AC 70 ms
16,252 KB
testcase_16 AC 95 ms
18,256 KB
testcase_17 AC 65 ms
13,844 KB
testcase_18 AC 23 ms
7,576 KB
testcase_19 AC 29 ms
8,620 KB
testcase_20 AC 76 ms
17,264 KB
testcase_21 AC 45 ms
11,204 KB
testcase_22 AC 45 ms
12,204 KB
testcase_23 AC 35 ms
10,164 KB
testcase_24 AC 69 ms
16,080 KB
testcase_25 AC 77 ms
15,632 KB
testcase_26 AC 31 ms
8,868 KB
testcase_27 AC 22 ms
7,428 KB
testcase_28 AC 33 ms
9,556 KB
testcase_29 AC 11 ms
5,824 KB
testcase_30 AC 47 ms
12,244 KB
testcase_31 AC 108 ms
20,128 KB
testcase_32 AC 21 ms
7,252 KB
testcase_33 AC 60 ms
13,036 KB
testcase_34 AC 70 ms
14,936 KB
testcase_35 AC 9 ms
5,376 KB
testcase_36 AC 82 ms
16,216 KB
testcase_37 AC 84 ms
18,720 KB
testcase_38 AC 31 ms
9,564 KB
testcase_39 AC 97 ms
20,832 KB
testcase_40 AC 53 ms
12,260 KB
testcase_41 AC 61 ms
15,252 KB
testcase_42 AC 63 ms
15,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
#endif
typedef long long  ll;
typedef pair<int,int> pii; typedef pair<ll,ll> pll;
const int INF = 1e9; const long long LINF = 1e18;
const int MOD = 998244353; const int MOD1 = 1e9+7;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) x.begin(), x.end()
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
void yorn(bool ans){cout << (ans?"Yes":"No") << endl; return;}

// しばらくはsize_tをキャストに任せてみようかな
int main(){
    int n,m; cin >> n >> m;
    string s; cin >> s;
    int l = (n+m)*2;

    /*vector<int> w(l),c(l),a1(l),a2(l);
    if(s.at(0)=='C'||s.back()=='W'){cout << "No" << endl; return 0;}

    if(s.at(0)=='A') a1.at(0) = 1;
    if(s.back()=='A') a2.at(0) = 1;
    for(int i=1;i<l;i++){
        if(s.at(i)=='C') c.at(i)++;
        c.at(i) += c.at(i-1);
        if(s.at(i) =='A') a1.at(i)++;
        a1.at(i) += a1.at(i-1);
    }
    for(int i=l-2;i>=0;i--){
        if(s.at(i)=='W') w.at(i)++;
        w.at(i) += w.at(i+1);
        if(s.at(i) =='A') a2.at(i)++;
        a2.at(i) += a2.at(i+1);
    }
    rep(i,l) cout << a1.at(i) << ' '; cout << endl;
    rep(i,l) cout << c.at(i) << ' '; cout << endl;
    rep(i,l) cout << a2.at(i) << ' '; cout << endl;
    rep(i,l) cout << w.at(i) << ' '; cout << endl;
    rep(i,l){
        if(a1.at(i)-c.at(i)<0 || a2.at(i)-w.at(i)<0){
            cout << "No" << endl; return 0;
        }
    }
    cout << "Yes" << endl;*/

    set<int> a,w,c;
    rep(i,l){
        if(s.at(i)=='A') a.insert(i);
        if(s.at(i)=='W') w.insert(i);
        if(s.at(i)=='C') c.insert(i);
    }
    //bool ans = true;
    for(auto i:c){
        if(*begin(a)<i) a.erase(*begin(a));
        else{cout << "No" << endl; return 0;}
    }
    for(auto i:a){
        if(*begin(w)<i) w.erase(*begin(w));
        else{cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
}
0