Submission #63033450
Source Code Expand
import * as fs from 'fs';
let _pendingInput = "";
const _decoder = new TextDecoder();
function input(): string {
while (true) {
const nl = _pendingInput.indexOf("\n");
if (nl >= 0) {
const line = _pendingInput.substring(0, nl); // 改行含まず
_pendingInput = _pendingInput.substring(nl + 1);
return line;
}
const stdin = 0;
const buf = new Uint8Array(1024);
const nread = fs.readSync(stdin, buf);
if (nread > 0) {
const bufView = new Uint8Array(buf.buffer, 0, nread);
_pendingInput += _decoder.decode(bufView, { stream: true });
} else {
// EOF
// 競プロでは事前に行数が分かっている想定なので、それ以上読もうとするのはエラー
// 改行で終わっていないテキストがあった場合、それは返さない
// _pendingInput += _decoder.decode();
// return null;
throw new Error('Unexpected EOF');
}
}
}
function isok(s: string) {
const stack: string[] = []
for (let i = 0; i < s.length; i++) {
const c = s[i]
switch (c) {
case "(":
case "[":
case "<":
stack.push(c)
break;
case ")":
if (stack.pop() != "(") {
return false;
}
break;
case "]":
if (stack.pop() != "[") {
return false;
}
break;
case ">":
if (stack.pop() != "<") {
return false;
}
break;
}
}
return stack.length == 0;
}
function main() {
const s = input()
console.log(isok(s) ? "Yes" : "No");
}
main();
Submission Info
| Submission Time | |
|---|---|
| Task | D - Colorful Bracket Sequence |
| User | bugtori |
| Language | TypeScript 5.1 (Node.js 18.16.1) |
| Score | 400 |
| Code Size | 1950 Byte |
| Status | AC |
| Exec Time | 61 ms |
| Memory | 53176 KiB |
Compile Error
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 40 ms | 43024 KiB |
| example_01.txt | AC | 40 ms | 42640 KiB |
| example_02.txt | AC | 39 ms | 43020 KiB |
| hand_00.txt | AC | 59 ms | 53176 KiB |
| hand_01.txt | AC | 55 ms | 51920 KiB |
| hand_02.txt | AC | 60 ms | 53128 KiB |
| hand_03.txt | AC | 40 ms | 42936 KiB |
| hand_04.txt | AC | 61 ms | 52920 KiB |
| hand_05.txt | AC | 40 ms | 42876 KiB |
| hand_06.txt | AC | 40 ms | 42864 KiB |
| random_00.txt | AC | 55 ms | 52072 KiB |
| random_01.txt | AC | 59 ms | 53112 KiB |
| random_02.txt | AC | 56 ms | 53012 KiB |
| random_03.txt | AC | 59 ms | 52116 KiB |
| random_04.txt | AC | 57 ms | 53104 KiB |
| random_05.txt | AC | 58 ms | 52440 KiB |
| random_06.txt | AC | 50 ms | 48328 KiB |
| random_07.txt | AC | 56 ms | 52576 KiB |
| random_08.txt | AC | 58 ms | 52324 KiB |
| random_09.txt | AC | 56 ms | 52412 KiB |
| random_10.txt | AC | 56 ms | 51932 KiB |
| random_11.txt | AC | 56 ms | 51896 KiB |
| random_12.txt | AC | 56 ms | 52100 KiB |
| random_13.txt | AC | 55 ms | 51924 KiB |
| random_14.txt | AC | 56 ms | 52132 KiB |
| random_15.txt | AC | 54 ms | 51964 KiB |
| random_16.txt | AC | 54 ms | 51976 KiB |
| random_17.txt | AC | 53 ms | 51876 KiB |
| random_18.txt | AC | 55 ms | 51736 KiB |
| random_19.txt | AC | 53 ms | 51952 KiB |
| random_20.txt | AC | 55 ms | 51880 KiB |
| random_21.txt | AC | 55 ms | 51900 KiB |
| random_22.txt | AC | 55 ms | 51876 KiB |
| random_23.txt | AC | 58 ms | 51980 KiB |
| random_24.txt | AC | 56 ms | 52064 KiB |
| random_25.txt | AC | 53 ms | 52100 KiB |
| random_26.txt | AC | 56 ms | 52008 KiB |
| random_27.txt | AC | 55 ms | 51924 KiB |
| random_28.txt | AC | 56 ms | 51740 KiB |
| random_29.txt | AC | 54 ms | 51936 KiB |