Submission #74675516
Source Code Expand
function main(stdin) {
// eslint-disable-next-line unused-imports/no-unused-vars, no-unused-vars
const { next, nextstr, nextbig, nexts, nextssort, nextm, xArray } = makeInputReader(stdin)
const n = next()
const ab = Array.from({ length: 11 }, () => Array.from({ length: 2 }, () => 0))
const sets = Array.from({ length: 11 }, () =>
Array.from({ length: 11 }, () => new Set()))
for (let i = 0; i < n; i++) {
const [a, b] = nexts(2)
ab[i][0] = a
ab[i][1] = b
}
const m = next()
const strs = []
for (let i = 0; i < m; i++) {
const str = nextstr()
strs.push(str)
for (let j = 0; j < n; j++) {
const a = ab[j][0]
const b = ab[j][1]
if (str.length !== a) {
continue
}
else {
sets[a][b].add(str[b - 1])
}
}
}
const res = []
for (const str of strs) {
if (str.length !== n) {
res.push('No')
continue
}
let i = 0
for (; i < str.length; i++) {
const ch = str[i]
const a = ab[i][0]
const b = ab[i][1]
if (!sets[a][b].has(ch)) {
res.push('No')
break
}
}
if (i === str.length) {
res.push('Yes')
}
}
return res.join('\n')
}
class PriorityQueue {
constructor() {
this.a = []
}
push(num, inc) {
const a = this.a
let i = a.length
for (let j; i; i = j) {
j = i - 1 >> 1
if (a[j][0] <= num) {
break
}
a[i] = a[j]
}
a[i] = [num, inc]
}
pop() {
const a = this.a
const r = a[0]
const x = a.pop()
const k = a.length >> 1
let i = 0
for (let j; i < k; i = j) {
j = (i << 1) + 1
if (a[j + 1] && a[j + 1][0] < a[j][0]) {
j++
}
if (x[0] <= a[j][0]) {
break
}
a[i] = a[j]
}
if (a.length) {
a[i] = x
}
return r
}
pushPop(num, inc) {
const a = this.a
const r = a[0]
const k = a.length >> 1
if (!a.length || r[0] >= num) {
return [num, inc]
}
let i = 0
for (let j; i < k; i = j) {
j = (i << 1) + 1
if (a[j + 1] && a[j + 1][0] < a[j][0]) {
j++
}
if (num <= a[j][0]) {
break
}
a[i] = a[j]
}
a[i] = [num, inc]
return r
}
popPush(num, inc) {
const a = this.a
const r = a[0]
const k = a.length >> 1
let i = 0
for (let j; i < k; i = j) {
j = (i << 1) + 1
if (a[j + 1] && a[j + 1][0] < a[j][0]) {
j++
}
if (num <= a[j][0]) {
break
}
a[i] = a[j]
}
a[i] = [num, inc]
return r
}
get size() {
return this.a.length
}
get top() {
return this.a[0]
}
}
function makeInputReader(input) {
const cin = input.trim().split(/ |\n/)
let cid = 0
function createNDArray(shape, fillFn) {
if (shape.length === 0)
return fillFn()
const [dim, ...rest] = shape
return Array.from({ length: dim }, () => createNDArray(rest, fillFn))
}
return {
next: () => Number(cin[cid++]),
nextstr: () => cin[cid++],
nextbig: () => BigInt(cin[cid++]),
nexts: (n, addNum = 0, parse = true) =>
parse ? cin.slice(cid, cid += n).map(s => Number(s) + addNum) : cin.slice(cid, cid += n),
nextssort: (n, parse = true, desc = false) =>
parse
? cin.slice(cid, cid += n).map(Number).sort((a, b) => desc ? b - a : a - b)
: cin.slice(cid, cid += n).sort((a, b) => desc ? b.localeCompare(a) : a.localeCompare(b)),
nextm: (h, w, parse = true) => {
const res = []
for (let i = 0; i < h; i++) {
const row = cin.slice(cid, cid += w)
res.push(parse ? row.map(Number) : row)
}
return res
},
xArray: createNDArray,
}
}
if (require.main === module) {
const fs = require('node:fs')
const input = fs.readFileSync('/dev/stdin', 'utf8')
console.log(main(input))
}
module.exports = { main }
Submission Info
| Submission Time |
|
| Task |
C - Fishbones |
| User |
xhksun |
| Language |
JavaScript (Node.js 22.19.0) |
| Score |
300 |
| Code Size |
4081 Byte |
| Status |
AC |
| Exec Time |
153 ms |
| Memory |
85680 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00-sample-01.txt, 00-sample-02.txt |
| All |
00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00-sample-01.txt |
AC |
40 ms |
42052 KiB |
| 00-sample-02.txt |
AC |
23 ms |
42160 KiB |
| 01-01.txt |
AC |
85 ms |
54092 KiB |
| 01-02.txt |
AC |
55 ms |
65900 KiB |
| 01-03.txt |
AC |
80 ms |
78416 KiB |
| 01-04.txt |
AC |
60 ms |
67140 KiB |
| 01-05.txt |
AC |
79 ms |
72784 KiB |
| 01-06.txt |
AC |
76 ms |
69864 KiB |
| 01-07.txt |
AC |
152 ms |
81788 KiB |
| 01-08.txt |
AC |
153 ms |
81912 KiB |
| 01-09.txt |
AC |
43 ms |
53860 KiB |
| 01-10.txt |
AC |
61 ms |
65864 KiB |
| 01-11.txt |
AC |
42 ms |
54048 KiB |
| 01-12.txt |
AC |
84 ms |
76440 KiB |
| 01-13.txt |
AC |
73 ms |
68804 KiB |
| 01-14.txt |
AC |
64 ms |
64048 KiB |
| 01-15.txt |
AC |
136 ms |
85564 KiB |
| 01-16.txt |
AC |
146 ms |
85680 KiB |
| 01-17.txt |
AC |
129 ms |
82252 KiB |
| 01-18.txt |
AC |
132 ms |
82056 KiB |
| 01-19.txt |
AC |
124 ms |
82228 KiB |
| 01-20.txt |
AC |
129 ms |
82276 KiB |
| 01-21.txt |
AC |
127 ms |
82124 KiB |
| 01-22.txt |
AC |
136 ms |
82332 KiB |
| 01-23.txt |
AC |
140 ms |
82220 KiB |