Submission #51604244
Source Code Expand
async function main() {
const [h, w, m] = parseInts(await readOneLine());
const taxs: [number, number, number][] = [];
for (const i of range(m)) {
taxs.push(parseInts(await readOneLine()) as [number, number, number]);
}
const hFinalized = new Array(h).fill(false);
let hFinalizedCount = 0;
const wFinalized = new Array(w).fill(false);
let wFinalizedCount = 0;
const colorCounts = new Map<number, number>();
for (const i of range(m)) {
const [h1w2, index, color] = taxs[taxs.length - 1 - i];
if (h1w2 === 1) {
if (hFinalized[index - 1]) {
continue;
} else {
hFinalized[index - 1] = true;
hFinalizedCount++;
colorCounts.set(color, (colorCounts.get(color) ?? 0) + (w - wFinalizedCount));
if (hFinalizedCount === h) {
break;
}
}
} else {
if (wFinalized[index - 1]) {
continue;
} else {
wFinalized[index - 1] = true;
wFinalizedCount++;
colorCounts.set(color, (colorCounts.get(color) ?? 0) + (h - hFinalizedCount));
if (wFinalizedCount === w) {
break;
}
}
}
}
const notFinalizedCount = hFinalized.filter((i) => !i).length * wFinalized.filter((i) => !i).length;
if (notFinalizedCount !== 0) {
colorCounts.set(0, (colorCounts.get(0) ?? 0) + notFinalizedCount);
}
const colors = Array.from(colorCounts.keys()).sort((a, b) => a - b);
console.log(colors.length);
for (const color of colors) {
console.log(color, colorCounts.get(color));
}
}
// --------------------------------------------------------------------------
function sum(array: number[]): number {
let sum = 0;
for (const i of array) {
sum += i;
}
return sum;
}
const parseInts = (string: string) => string.split(" ").map((i) => parseInt(i));
function* range(max: number) {
for (let i = 0; i < max; i++) {
yield i;
}
}
// --------------------------------------------------------------------------
function createReadOneLine() {
const generator = (async function* () {
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin });
for await (const line of rl) {
yield line as string;
}
})();
return async function readOneLine() {
return (await generator.next()).value as string;
};
}
const readOneLine = createReadOneLine();
main();
Submission Info
| Submission Time | |
|---|---|
| Task | E - Paint |
| User | tkntkn |
| Language | TypeScript 5.1 (Node.js 18.16.1) |
| Score | 450 |
| Code Size | 2499 Byte |
| Status | AC |
| Exec Time | 996 ms |
| Memory | 123836 KiB |
Compile Error
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 450 / 450 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt, sample01.txt, sample02.txt |
| All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | AC | 42 ms | 43052 KiB |
| sample01.txt | AC | 41 ms | 43100 KiB |
| sample02.txt | AC | 41 ms | 43324 KiB |
| testcase00.txt | AC | 877 ms | 116872 KiB |
| testcase01.txt | AC | 912 ms | 120488 KiB |
| testcase02.txt | AC | 863 ms | 115700 KiB |
| testcase03.txt | AC | 936 ms | 120124 KiB |
| testcase04.txt | AC | 861 ms | 117428 KiB |
| testcase05.txt | AC | 941 ms | 120588 KiB |
| testcase06.txt | AC | 873 ms | 118064 KiB |
| testcase07.txt | AC | 927 ms | 121248 KiB |
| testcase08.txt | AC | 868 ms | 119588 KiB |
| testcase09.txt | AC | 925 ms | 120444 KiB |
| testcase10.txt | AC | 902 ms | 120448 KiB |
| testcase11.txt | AC | 939 ms | 120780 KiB |
| testcase12.txt | AC | 852 ms | 110316 KiB |
| testcase13.txt | AC | 931 ms | 111288 KiB |
| testcase14.txt | AC | 880 ms | 109100 KiB |
| testcase15.txt | AC | 928 ms | 111012 KiB |
| testcase16.txt | AC | 886 ms | 111200 KiB |
| testcase17.txt | AC | 928 ms | 110904 KiB |
| testcase18.txt | AC | 799 ms | 120128 KiB |
| testcase19.txt | AC | 831 ms | 123836 KiB |
| testcase20.txt | AC | 608 ms | 106832 KiB |
| testcase21.txt | AC | 632 ms | 107552 KiB |
| testcase22.txt | AC | 621 ms | 107508 KiB |
| testcase23.txt | AC | 631 ms | 104928 KiB |
| testcase24.txt | AC | 639 ms | 103036 KiB |
| testcase25.txt | AC | 819 ms | 110292 KiB |
| testcase26.txt | AC | 780 ms | 108872 KiB |
| testcase27.txt | AC | 684 ms | 106612 KiB |
| testcase28.txt | AC | 763 ms | 108256 KiB |
| testcase29.txt | AC | 831 ms | 108284 KiB |
| testcase30.txt | AC | 975 ms | 121364 KiB |
| testcase31.txt | AC | 967 ms | 120832 KiB |
| testcase32.txt | AC | 948 ms | 120384 KiB |
| testcase33.txt | AC | 973 ms | 123352 KiB |
| testcase34.txt | AC | 967 ms | 122668 KiB |
| testcase35.txt | AC | 985 ms | 121060 KiB |
| testcase36.txt | AC | 996 ms | 121260 KiB |
| testcase37.txt | AC | 979 ms | 122724 KiB |
| testcase38.txt | AC | 985 ms | 122664 KiB |
| testcase39.txt | AC | 984 ms | 122728 KiB |