結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー milanis48663220milanis48663220
提出日時 2023-05-19 22:32:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,849 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 132,844 KB
実行使用メモリ 21,892 KB
最終ジャッジ日時 2023-08-23 00:26:51
合計ジャッジ時間 45,852 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

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<int> 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);
        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);
        debug_value(c)
        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{
            if(fl) ans = fr;
            ans = true;
        }
        x[il] = ans;
        seg.set(c, 0);
        // for(auto [i, f]: st) cout << f << ' ';
        // cout << endl;
    }
    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