Task: | Bored Uolevi |
Sender: | team univelka |
Submission time: | 2017-09-19 19:08:11 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.03 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | WRONG ANSWER | 0.07 s | details |
#5 | WRONG ANSWER | 0.07 s | details |
#6 | WRONG ANSWER | 0.10 s | details |
#7 | WRONG ANSWER | 0.08 s | details |
#8 | WRONG ANSWER | 0.07 s | details |
#9 | WRONG ANSWER | 0.09 s | details |
#10 | WRONG ANSWER | 0.06 s | details |
#11 | WRONG ANSWER | 0.08 s | details |
#12 | WRONG ANSWER | 0.07 s | details |
#13 | WRONG ANSWER | 0.10 s | details |
#14 | RUNTIME ERROR | 0.22 s | details |
#15 | WRONG ANSWER | 0.10 s | details |
#16 | WRONG ANSWER | 0.10 s | details |
#17 | RUNTIME ERROR | 0.22 s | details |
#18 | RUNTIME ERROR | 0.21 s | details |
#19 | ACCEPTED | 0.11 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | ACCEPTED | 0.05 s | details |
#22 | ACCEPTED | 0.03 s | details |
Code
#include <iostream> #include <algorithm> const int N = 2000; bool crossed[N][N]; void trace_x(int x1, int y1, int x2, int y2) { if (x1 > x2) { trace_x(x2, y2, x1, y1); } else { int dx = x2-x1; int dy = y2-y1; for (int k = 0; k < dx; ++k) { int y = y1 + (k * dy) / dx; bool ey = ((k * dy) % dx != 0); int ny = y1 + ((k+1) * dy) / dx; bool ney = (((k+1) * dy) % dx != 0); if (y != ny) { if (y < ny) { if (ney) crossed[x1+k][ny] = true; crossed[x1+k][y] = true; } else { if (ey) crossed[x1+k][y] = true; crossed[x1+k][ny] = true; } } else { if (ey || ney) crossed[x1+k][y] = true; } } } } void trace_y(int x1, int y1, int x2, int y2) { if (y1 > y2) { trace_y(x2, y2, x1, y1); } else { int dx = x2-x1; int dy = y2-y1; for (int k = 0; k < dy; ++k) { int x = x1 + (k * dx) / dy; bool ex = ((k * dx) % dy != 0); int nx = x1 + ((k+1) * dx) / dy; bool nex = (((k+1) * dx) % dy != 0); if (x != nx) { if (x < nx) { if (nex) crossed[nx][y1+k] = true; crossed[x][y1+k] = true; } else { if (ex) crossed[x][y1+k] = true; crossed[nx][y1+k] = true; } } else { if (ex || nex) crossed[x][y1+k] = true; } } } } int main() { int n; std::cin >> n; for (int i = 0; i < n; ++i) { int x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; if (std::abs(x1-x2) < std::abs(y1-y2)) { trace_y(x1, y1, x2, y2); } else { trace_x(x1, y1, x2, y2); } } int count = 0; for (int y = 0; y < N; ++y) { for (int x = 0; x < N; ++x) { count += (crossed[x][y] ? 1 : 0); } } std::cout << count << '\n'; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3 0 0 5 5 0 5 5 0 0 5 5 0 |
correct output |
---|
9 |
user output |
---|
9 |
Test 2
Verdict: ACCEPTED
input |
---|
1 0 0 4 3 |
correct output |
---|
6 |
user output |
---|
6 |
Test 3
Verdict: ACCEPTED
input |
---|
2 0 0 4 3 1 0 3 3 |
correct output |
---|
6 |
user output |
---|
6 |
Test 4
Verdict: WRONG ANSWER
input |
---|
2000 1720 121 1506 1981 477 134 1088 1890 1219 594 628 1010 650 1512 115 1859 ... |
correct output |
---|
1784643 |
user output |
---|
1786015 |
Test 5
Verdict: WRONG ANSWER
input |
---|
2000 409 388 1224 1446 334 505 914 1979 427 622 811 1597 1714 457 20 1682 ... |
correct output |
---|
1775295 |
user output |
---|
1777625 |
Test 6
Verdict: WRONG ANSWER
input |
---|
2000 1743 735 874 1470 779 1076 1244 1660 704 1244 1136 399 1350 1110 41 686 ... |
correct output |
---|
1783040 |
user output |
---|
1785040 |
Test 7
Verdict: WRONG ANSWER
input |
---|
2000 1500 1420 1914 482 1506 158 119 345 1772 787 1549 141 1032 1561 318 1529 ... |
correct output |
---|
1755891 |
user output |
---|
1758038 |
Test 8
Verdict: WRONG ANSWER
input |
---|
2000 1276 1427 1714 1359 824 118 72 1042 252 1154 921 1831 1951 742 546 205 ... |
correct output |
---|
1790303 |
user output |
---|
1792492 |
Test 9
Verdict: WRONG ANSWER
input |
---|
2000 1624 1147 884 41 1917 1503 321 1182 324 1656 1432 87 441 1388 1894 1020 ... |
correct output |
---|
1781162 |
user output |
---|
1782666 |
Test 10
Verdict: WRONG ANSWER
input |
---|
2000 64 1000 1478 678 1228 1904 49 1198 1544 1330 1825 1037 100 277 291 608 ... |
correct output |
---|
1763650 |
user output |
---|
1764858 |
Test 11
Verdict: WRONG ANSWER
input |
---|
2000 817 354 1426 168 1163 905 1346 33 631 8 1256 160 1511 1407 998 1021 ... |
correct output |
---|
1787840 |
user output |
---|
1790346 |
Test 12
Verdict: WRONG ANSWER
input |
---|
2000 864 391 493 1719 1414 955 1430 415 739 502 1061 383 56 31 174 1303 ... |
correct output |
---|
1779897 |
user output |
---|
1781286 |
Test 13
Verdict: WRONG ANSWER
input |
---|
2000 1679 692 1203 242 998 850 998 255 1615 1233 1412 1956 162 1991 98 1409 ... |
correct output |
---|
1769951 |
user output |
---|
1772310 |
Test 14
Verdict: RUNTIME ERROR
input |
---|
2000 679 2000 2000 0 0 1508 2000 0 0 1408 2000 0 795 2000 2000 0 ... |
correct output |
---|
3105373 |
user output |
---|
(empty) |
Test 15
Verdict: WRONG ANSWER
input |
---|
2000 0 927 2000 0 206 2000 2000 0 0 1594 2000 0 0 1546 2000 0 ... |
correct output |
---|
3084266 |
user output |
---|
3086953 |
Test 16
Verdict: WRONG ANSWER
input |
---|
2000 0 538 2000 0 105 2000 2000 0 0 885 2000 0 672 2000 2000 0 ... |
correct output |
---|
3086598 |
user output |
---|
3089978 |
Test 17
Verdict: RUNTIME ERROR
input |
---|
2000 1368 2000 2000 0 411 2000 2000 0 0 833 2000 0 0 1961 2000 0 ... |
correct output |
---|
3104601 |
user output |
---|
(empty) |
Test 18
Verdict: RUNTIME ERROR
input |
---|
2000 0 818 2000 0 48 2000 2000 0 1277 2000 2000 0 0 1577 2000 0 ... |
correct output |
---|
3115062 |
user output |
---|
(empty) |
Test 19
Verdict: ACCEPTED
input |
---|
2000 0 0 2000 1 0 1 2000 2 0 2 2000 3 0 3 2000 4 ... |
correct output |
---|
4000000 |
user output |
---|
4000000 |
Test 20
Verdict: ACCEPTED
input |
---|
3 2000 0 0 2000 0 0 1 1 2000 1999 1999 2000 |
correct output |
---|
2002 |
user output |
---|
2002 |
Test 21
Verdict: ACCEPTED
input |
---|
1 0 0 1 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 22
Verdict: ACCEPTED
input |
---|
2 0 0 1 1 0 1 1 0 |
correct output |
---|
1 |
user output |
---|
1 |