結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー milanis48663220milanis48663220
提出日時 2023-05-19 23:48:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,050 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 133,684 KB
実行使用メモリ 21,812 KB
最終ジャッジ日時 2023-08-23 01:55:01
合計ジャッジ時間 15,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 292 ms
12,596 KB
testcase_12 AC 296 ms
12,576 KB
testcase_13 AC 287 ms
12,628 KB
testcase_14 AC 287 ms
12,576 KB
testcase_15 AC 295 ms
12,796 KB
testcase_16 AC 297 ms
12,740 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 288 ms
12,648 KB
testcase_20 AC 298 ms
12,624 KB
testcase_21 AC 371 ms
21,620 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 365 ms
21,604 KB
testcase_25 WA -
testcase_26 AC 364 ms
21,612 KB
testcase_27 AC 351 ms
21,592 KB
testcase_28 WA -
testcase_29 AC 359 ms
21,620 KB
testcase_30 AC 351 ms
21,608 KB
testcase_31 AC 184 ms
21,608 KB
testcase_32 AC 185 ms
21,708 KB
testcase_33 AC 185 ms
21,680 KB
testcase_34 WA -
testcase_35 AC 199 ms
21,580 KB
testcase_36 AC 199 ms
21,688 KB
testcase_37 WA -
testcase_38 AC 291 ms
12,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/segtree>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int op(int x, int y){
    return x+y;
}

int e(){
    return 0;
}

using Seg = atcoder::segtree<int, op, e>;

void solve(){
    int n; cin >> n;
    vector<bool> x(n);
    vector<bool> del(n);
    set<int> st;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        assert(s == "True" || s == "False");
        x[i] = (s[0] == 'T');
        st.insert(i);
    }
    Seg seg(vector<int>(n-1, 1));
    vector<string> y(n-1);
    vector<int> s(n-1);
    for(int i = 0; i < n-1; i++) cin >> y[i];
    for(int i = 0; i < n-1; i++) {
        cin >> s[i];
    }
    for(int i = 0; i < n-1; i++){
        auto g = [&](int x){
            return x < s[i];
        };
        int c = seg.max_right(0, g);
        bool ans = false;
        auto p = st.upper_bound(c);
        assert(p != st.end());
        int ir = *p;
        int il = *prev(p);
        bool fl = x[il];
        bool fr = x[ir];
        assert(il <= c);
        assert(ir == c+1);
        del[ir] = true;
        assert(!del[il]);
        assert(il >= 0);
        assert(ir < n);
        assert(seg.get(c) == 1);
        assert(seg.prod(0, c+1) == s[i]);
        st.erase(ir);
        if(y[c] == "and"){
            ans = (fl&&fr); 
        }else if(y[c] == "or"){
            ans = (fl||fr); 
        }else if(y[c] == "xor"){
            ans = (fl!=fr);
        }else{
            assert(y[c] == "imp");
            if(fl) ans = fr;
            ans = true;
        }
        x[il] = ans;
        seg.set(c, 0);
        // for(auto [i, f]: st) cout << f << ' ';
        // cout << endl;
    }
    assert(!del[0]);
    assert(*st.begin() == 0);
    if(x[0]){
        cout << "True\n";
    }else{
        cout << "False\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int t; cin >> t;
    while(t--) solve();
}
0