Task: | Spiraali |
Sender: | AnttiE |
Submission time: | 2021-10-05 16:06:54 +0300 |
Language: | Node.js |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.43 s | 1 | details |
#2 | RUNTIME ERROR | 0.43 s | 2 | details |
#3 | RUNTIME ERROR | 0.43 s | 3 | details |
Code
const input = () => new Promise(r => process.stdin.once("data", d => r(d.toString().trim()))); (async () => { // -- START -- const dist = (r1, c1, r2, c2) => Math.abs(r2 - r1) + Math.abs(c2 - c1); // ngl not proud of this one // + miksi koordinaatit alkaa 1,1 eikä 0,0... const solve = (size, r, c) => { const centers = [ [size / 2, 1], // left [size, size / 2], // bottom [(size / 2) + 1, size], // right [1, (size / 2) + 1] // top ]; for (const center in centers) { if (dist(...centers[center], r, c) <= (size / 2) - 1) { let ans; switch (center) { case "0": { ans = 0; for (let i = 0; i < (c - 1); i++) { ans += (size - 1 - (i * 2)) * 4; } ans += r - (c - 1); break; } case "1": { ans = size - 1; for (let i = 0; i < (size - r); i++) { ans += (size - 1 - (i * 2)) * 4 - 2; } ans += c - (size - r); break; } case "2": { ans = (size - 1) * 2; for (let i = 0; i < (size - c); i++) { ans += (size - 1 - (i * 2)) * 4 - 4; } ans += (size - r) - (size - c) + 1; break; } case "3": { ans = (size - 1) * 3; for (let i = 0; i < (r - 1); i++) { ans += (size - 1 - (i * 2)) * 4 - 7; } ans += (size - c) + 1; break; } } return ans ?? 0; } } }; const [size, count] = (await input()).split(" ").map(Number); const tests = []; for (let i = 0; i < count; i++) tests.push((await input()).split(" ").map(Number)); for (const test of tests) console.log(solve(size, test[0], test[1]).toString()); // -- END -- process.exit(0); })();
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
input |
---|
10 100 1 1 1 2 1 3 1 4 ... |
correct output |
---|
1 36 35 34 33 ... |
user output |
---|
(empty) |
Error:
/box/input/code.js:53 return ans ?? 0; ^ Synt...
Test 2
Group: 2
Verdict: RUNTIME ERROR
input |
---|
1000 1000 371 263 915 322 946 880 53 738 ... |
correct output |
---|
773533 312166 206053 200080 593922 ... |
user output |
---|
(empty) |
Error:
/box/input/code.js:53 return ans ?? 0; ^ Synt...
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
(empty) |
Error:
/box/input/code.js:53 return ans ?? 0; ^ Synt...