Task: | Spiraali |
Sender: | motsgar |
Submission time: | 2021-10-04 02:21:45 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1 | details |
#2 | WRONG ANSWER | 0.01 s | 2 | details |
#3 | WRONG ANSWER | 0.01 s | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; int n, t; int start; int get(int p) { return n * n + p * ((-4 * (p - 1) * 2 - 4) / 2) - p; } int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> t; int centerX = n / 2 + 1; int centerY = n / 2; if (n % 2 == 1) { centerY++; } for (int i = 0; i < t; i++) { int x, y; cin >> x >> y; int rengas = max(abs(centerX - x), abs(centerY - y)); int arvo = get(rengas); if (n % 2 == 0) { if (y == centerY + rengas && x < centerX + rengas) { arvo += rengas; arvo += x - (centerX - rengas); } else if (x == centerX - rengas) { arvo += y - centerY; } else if (y == centerY - rengas) { arvo -= rengas; arvo -= x - (centerX - rengas); } else { arvo -= rengas + 2 * (rengas - 1); arvo -= y - (centerY - rengas); } } else { if (y == centerY - rengas && x > centerX - rengas) { arvo += rengas; arvo -= x - centerX - rengas; } else if (x == centerX + rengas) { arvo -= y - centerY; } else if (y == centerY + rengas) { arvo -= rengas; arvo += x - (centerX + rengas); } else { arvo -= rengas + 2 * (rengas - 1); arvo += y - (centerY + rengas); } } cout << arvo << "\n"; } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 100 1 1 1 2 1 3 1 4 ... |
correct output |
---|
1 36 35 34 33 ... |
user output |
---|
1 2 3 4 5 ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 1000 371 263 915 322 946 880 53 738 ... |
correct output |
---|
773533 312166 206053 200080 593922 ... |
user output |
---|
775217 313354 206187 197870 594542 ... Truncated |
Test 3
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
399311524 1643368629 2036373734 1163551112 368111459 ... Truncated |