結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 02:18:36 |
| 言語 | JavaScript (node v25.8.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 658 bytes |
| 記録 | |
| コンパイル時間 | 68 ms |
| コンパイル使用メモリ | 6,400 KB |
| 実行使用メモリ | 186,460 KB |
| 最終ジャッジ日時 | 2026-04-19 02:18:58 |
| 合計ジャッジ時間 | 21,255 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
function Main(input) {
input = input.split("\n");
const N = Number(input.shift());
const ans = [];
const stack = [];
const arr = [];
for (let i = 0; i < N; i++) {
const [q, c] = input[i].trim().split(" ");
if (q == "1") {
stack.push(c);
arr.push(c);
const l = stack.length;
if (l > 2) {
if (stack[l - 3] + stack[l - 2] + stack[l - 1] == "(|)") {
for (let i = 0; i < 3; i++) stack.pop();
}
}
} else {
if (arr.at(-1) == ")") {
stack.push("(");
stack.push("|");
}
arr.pop();
}
ans.push(stack.length > 0 ? "No" : "Yes");
}
console.log(ans.join("\n"));
}
Main(require("fs").readFileSync(0) + "")