結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー milanis48663220milanis48663220
提出日時 2023-05-19 22:17:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,759 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 131,100 KB
実行使用メモリ 21,852 KB
最終ジャッジ日時 2023-08-23 00:10:41
合計ジャッジ時間 16,962 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 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 337 ms
12,660 KB
testcase_12 AC 339 ms
12,708 KB
testcase_13 AC 341 ms
12,628 KB
testcase_14 AC 342 ms
12,708 KB
testcase_15 WA -
testcase_16 AC 341 ms
12,668 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 341 ms
12,720 KB
testcase_21 AC 427 ms
21,656 KB
testcase_22 WA -
testcase_23 AC 424 ms
21,600 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 423 ms
21,608 KB
testcase_28 WA -
testcase_29 AC 418 ms
21,672 KB
testcase_30 AC 418 ms
21,620 KB
testcase_31 AC 190 ms
21,608 KB
testcase_32 AC 192 ms
21,612 KB
testcase_33 AC 191 ms
21,820 KB
testcase_34 AC 204 ms
21,684 KB
testcase_35 AC 205 ms
21,664 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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 P = pair<int, bool>;
using Seg = atcoder::segtree<int, op, e>;

void solve(){
    int n; cin >> n;
    vector<bool> x(n);
    set<P> st;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        x[i] = s[0] == 'T';
        st.insert({i, x[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, true});
        assert(p != st.end());
        auto [ir, fr] = *p;
        auto [il, fl] = *prev(p);
        st.erase({ir, fr});
        st.erase({il, fl});
        if(y[i] == "and"){
            ans = fl&&fr; 
        }else if(y[i] == "or"){
            ans = fl||fr; 
        }else if(y[i] == "xor"){
            ans = fl!=fr; 
        }else{
            if(fl) ans = fr;
            ans = true;
        }
        st.insert({il, ans});
        seg.set(c, 0);
        // for(auto [i, f]: st) cout << f << ' ';
        // cout << endl;
    }
    assert(st.begin()->first == 0);
    if(st.begin()->second){
        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