Task: | Bored Uolevi |
Sender: | team univelka |
Submission time: | 2017-09-19 18:14:42 +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.05 s | details |
#4 | WRONG ANSWER | 0.09 s | details |
#5 | WRONG ANSWER | 0.07 s | details |
#6 | WRONG ANSWER | 0.09 s | details |
#7 | WRONG ANSWER | 0.07 s | details |
#8 | WRONG ANSWER | 0.07 s | details |
#9 | WRONG ANSWER | 0.07 s | details |
#10 | WRONG ANSWER | 0.08 s | details |
#11 | WRONG ANSWER | 0.07 s | details |
#12 | WRONG ANSWER | 0.06 s | details |
#13 | WRONG ANSWER | 0.07 s | details |
#14 | WRONG ANSWER | 0.09 s | details |
#15 | WRONG ANSWER | 0.10 s | details |
#16 | WRONG ANSWER | 0.08 s | details |
#17 | WRONG ANSWER | 0.09 s | details |
#18 | WRONG ANSWER | 0.12 s | details |
#19 | ACCEPTED | 0.09 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | ACCEPTED | 0.05 s | details |
#22 | ACCEPTED | 0.04 s | details |
Code
#include <iostream> #include <algorithm> const int N = 2000; bool crossed[N][N]; int gcd(int a, int b) { if (a < b) return gcd(b, a); if (b == 0) return a; return gcd(b, a % b); } void trace(int x1, int y1, int x2, int y2) { // 1 0 3 3 if (x1 <= x2) { int dx = x2-x1; int dy = y2-y1; for (int k = 0; k < x2-x1; ++k) { int y = y1 + (k * dy) / dx; bool not_eq_y = ((k * dy) % dx != 0); int next = y1 + ((k+1) * dy) / dx; bool not_eq_next = (((k+1) * dy) % dx != 0); if (y - next == 0) { if (not_eq_y || not_eq_next) { crossed[x1 + k][y] = true; } } else if (y > next) { if (not_eq_y) crossed[x1 + k][y] = true; for (int i = y-1; i >= next; --i) { crossed[x1 + k][i] = true; } } else { if (not_eq_next) crossed[x1 + k][next] = true; for (int i = next - 1; i >= y; --i) { crossed[x1 + k][i] = true; } } } } else { trace(x2, y2, x1, y1); } } 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; trace(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 |
---|
1785566 |
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 |
---|
1776751 |
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 |
---|
1783675 |
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 |
---|
1756908 |
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 |
---|
1791144 |
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 |
---|
1782157 |
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 |
---|
1764284 |
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 |
---|
1789195 |
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 |
---|
1780287 |
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 |
---|
1771393 |
Test 14
Verdict: WRONG ANSWER
input |
---|
2000 679 2000 2000 0 0 1508 2000 0 0 1408 2000 0 795 2000 2000 0 ... |
correct output |
---|
3105373 |
user output |
---|
3106724 |
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 |
---|
3084734 |
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 |
---|
3087211 |
Test 17
Verdict: WRONG ANSWER
input |
---|
2000 1368 2000 2000 0 411 2000 2000 0 0 833 2000 0 0 1961 2000 0 ... |
correct output |
---|
3104601 |
user output |
---|
3104802 |
Test 18
Verdict: WRONG ANSWER
input |
---|
2000 0 818 2000 0 48 2000 2000 0 1277 2000 2000 0 0 1577 2000 0 ... |
correct output |
---|
3115062 |
user output |
---|
3114090 |
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 |