結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー hongrockhongrock
提出日時 2023-05-19 22:05:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,927 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 200,264 KB
実行使用メモリ 12,432 KB
最終ジャッジ日時 2023-08-23 00:02:14
合計ジャッジ時間 9,775 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,900 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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 127 ms
11,184 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 124 ms
11,316 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 124 ms
11,188 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 141 ms
12,152 KB
testcase_24 AC 141 ms
12,284 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 143 ms
12,144 KB
testcase_29 WA -
testcase_30 AC 141 ms
12,140 KB
testcase_31 AC 80 ms
12,240 KB
testcase_32 AC 80 ms
12,136 KB
testcase_33 AC 80 ms
12,160 KB
testcase_34 AC 83 ms
12,140 KB
testcase_35 AC 83 ms
12,136 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1
 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using ui = unsigned int;
 
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1.0);

constexpr int N = 2e5 + 10;

int T, n;
bool f[N];
string g, op[N];
int pre[N], nxt[N], s[N];

bool calc(bool x, string &op, bool y){
  if(op == "and") return x & y;
  if(op == "or")  return x | y;
  if(op == "xor") return x ^ y;
  return x ? y : 1;
}

void add(int x, int v){
  for(; x<n; x+=lowbit(x)) s[x] += v;
}

int sum(int x){
  int ret = 0;
  for(; x>0; x-=lowbit(x))  ret += s[x];
  return ret;
}

void _main(){
  cin >> T;
  while(T--){
    cin >> n;
    rep(i, 1, n + 1){
      cin >> g;
      f[i] = g[0] == 'T';
    }
    nxt[0] = 1;
    pre[n] = n - 1;
    rep(i, 1, n){
      cin >> op[i];
      pre[i] = i - 1;
      nxt[i] = i + 1;
      s[i] = 0;
    }
    rep(i, 1, n)  add(i, 1);
    int x;
    rep(i, 1, n){
      cin >> x;
      int low = 1, top = n - 1, mid, key = 1;
      while(low <= top){
        mid = low + top >> 1;
        if(sum(mid) <= x){
          key = max(key, mid);
          low = mid + 1;
        } else {
          top = mid - 1;
        }
      }
      x = key;
      add(x, -1);
      f[nxt[x]] = calc(f[x], op[x], f[nxt[x]]);
      nxt[pre[x]] = nxt[x];
      pre[nxt[x]] = pre[x];
    }
    cout << (f[n] ? "True" : "False") << '\n';
  }
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}
0