結果
| 問題 | No.3753 Certainly a Cretan |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-19 00:40:45 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,613 bytes |
| 記録 | |
| コンパイル時間 | 1,017 ms |
| コンパイル使用メモリ | 212,000 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-10-02 20:56:14 |
| 合計ジャッジ時間 | 7,626 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 TLE * 1 |
| other | -- * 46 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, Q;
cin >> N >> Q;
string S;
cin >> S;
while (Q--) {
int t, x;
cin >> t >> x;
if (t == 1) {
int i = x - 1;
S[i] = (S[i] == 'Y' ? 'N' : 'Y');
} else {
int K = x;
long long ans = 0;
for (long long mask = 0; mask < (1LL << N); ++mask) {
if (__builtin_popcountll(mask) != K) continue;
int liar = 0;
bool ok = true;
for (int i = 0; i < N; ++i) {
bool is_liar = (mask >> i) & 1;
if (is_liar) {
++liar;
}
int honest = (i + 1) - liar;
int same;
if (is_liar) {
same = liar;
} else {
same = honest;
}
bool correct_yes = same * 2 > i + 1;
bool answer_yes;
if (is_liar) {
answer_yes = !correct_yes;
} else {
answer_yes = correct_yes;
}
if (answer_yes != (S[i] == 'Y')) {
ok = false;
break;
}
}
if (ok) {
++ans;
}
}
cout << ans << '\n';
}
}
}