結果

問題 No.2240 WAC
ユーザー umimelumimel
提出日時 2023-03-10 22:13:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 173,736 KB
実行使用メモリ 22,516 KB
最終ジャッジ日時 2023-10-18 07:56:07
合計ジャッジ時間 4,639 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_10 AC 112 ms
22,516 KB
testcase_11 AC 123 ms
22,516 KB
testcase_12 AC 118 ms
22,516 KB
testcase_13 AC 31 ms
10,040 KB
testcase_14 AC 13 ms
6,492 KB
testcase_15 AC 64 ms
16,144 KB
testcase_16 AC 77 ms
18,152 KB
testcase_17 AC 52 ms
13,740 KB
testcase_18 AC 20 ms
7,472 KB
testcase_19 AC 24 ms
8,512 KB
testcase_20 AC 71 ms
17,160 KB
testcase_21 AC 38 ms
11,100 KB
testcase_22 AC 42 ms
12,100 KB
testcase_23 AC 32 ms
10,056 KB
testcase_24 AC 66 ms
15,952 KB
testcase_25 AC 62 ms
15,524 KB
testcase_26 AC 25 ms
8,764 KB
testcase_27 AC 17 ms
7,320 KB
testcase_28 AC 29 ms
9,452 KB
testcase_29 AC 10 ms
5,720 KB
testcase_30 AC 43 ms
12,136 KB
testcase_31 AC 85 ms
20,020 KB
testcase_32 AC 18 ms
7,144 KB
testcase_33 AC 46 ms
12,932 KB
testcase_34 AC 57 ms
14,832 KB
testcase_35 AC 8 ms
5,272 KB
testcase_36 AC 68 ms
16,108 KB
testcase_37 AC 80 ms
18,556 KB
testcase_38 AC 31 ms
9,584 KB
testcase_39 AC 95 ms
20,668 KB
testcase_40 AC 43 ms
12,156 KB
testcase_41 AC 59 ms
15,148 KB
testcase_42 AC 60 ms
14,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    string s; cin >> s;

    set<ll> a, w, c;
    rep(i, (ll)s.size()){
        if(s[i]=='A'){
            a.insert(i);
        }else if(s[i]=='W'){
            w.insert(-i);
        }else{
            c.insert(i);
        }
    }

    for(auto itr=w.begin(); itr!=w.end(); itr++){
        ll idx = -*itr;
        auto itr2 = a.end();
        itr2--;
        if(idx < *itr2){
            a.erase(itr2);
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    for(auto itr=c.begin(); itr!=c.end(); itr++){
        ll idx = *itr;
        if(*a.begin() < idx){
            a.erase(a.begin());
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}
0