CSES - KILO 2017 3/5 - Results
Submission details
Task:Bored Uolevi
Sender:Semikolonisti
Submission time:2017-09-19 18:56:52 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.03 sdetails
#2ACCEPTED0.04 sdetails
#3ACCEPTED0.04 sdetails
#40.15 sdetails
#50.12 sdetails
#60.11 sdetails
#70.13 sdetails
#80.11 sdetails
#90.10 sdetails
#100.12 sdetails
#110.11 sdetails
#120.11 sdetails
#130.13 sdetails
#140.21 sdetails
#150.20 sdetails
#160.18 sdetails
#170.21 sdetails
#180.20 sdetails
#19ACCEPTED0.22 sdetails
#200.04 sdetails
#21ACCEPTED0.05 sdetails
#22ACCEPTED0.05 sdetails

Code

#include <bits/stdc++.h>
#define ll long long
#define ld float

using namespace std;

bool b[2222][2222];
#define K 2000
int main () {
    int n;
    cin>>n;
    for (int i = 0; i < n; i++) {
        ll x1, x2, y1, y2;
        cin>>x1>>y1>>x2>>y2;
        if (y1 == y2) continue;
        if (x1 == x2) continue;
        if (x1 > x2) {
            swap(x1, x2);
            swap(y1, y2);
        }
        ll k = y2 - y1;
        ll d = x2 - x1;
        
        for (ll x = x1; x < x2; x++) {
            ll a;
            ll e;
            if (k > 0) {
                a = y1 + (x - x1) * k / d;
                e = y1 + (x - x1 + 1) * k / d + (((x - x1 + 1) * k) % d != 0);
            } else {
                a = y1 + (x - x1) * k / d + (((x - x1) * k) % d != 0);
                e = y1 + (x - x1 + 1) * k / d;
            }
            if (a > e) swap(a, e);
            for (ll y = max(0LL, a - 5); y < e + 5; y++) {
                if (k * (x - x1) < (y + 1 - y1) * d && k * (x - x1 + 1) > (y - y1) * d) b[y][x] = 1;
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < K; j++) {
            ans += b[i][j];
        }
    }
    cout<<ans<<endl;
}

Test details

Test 1

Verdict:

input
3
0 0 5 5
0 5 5 0
0 5 5 0

correct output
9

user output
5

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:

input
2000
1720 121 1506 1981
477 134 1088 1890
1219 594 628 1010
650 1512 115 1859
...

correct output
1784643

user output
1247207

Test 5

Verdict:

input
2000
409 388 1224 1446
334 505 914 1979
427 622 811 1597
1714 457 20 1682
...

correct output
1775295

user output
1231100

Test 6

Verdict:

input
2000
1743 735 874 1470
779 1076 1244 1660
704 1244 1136 399
1350 1110 41 686
...

correct output
1783040

user output
1258450

Test 7

Verdict:

input
2000
1500 1420 1914 482
1506 158 119 345
1772 787 1549 141
1032 1561 318 1529
...

correct output
1755891

user output
1230223

Test 8

Verdict:

input
2000
1276 1427 1714 1359
824 118 72 1042
252 1154 921 1831
1951 742 546 205
...

correct output
1790303

user output
1243017

Test 9

Verdict:

input
2000
1624 1147 884 41
1917 1503 321 1182
324 1656 1432 87
441 1388 1894 1020
...

correct output
1781162

user output
1244578

Test 10

Verdict:

input
2000
64 1000 1478 678
1228 1904 49 1198
1544 1330 1825 1037
100 277 291 608
...

correct output
1763650

user output
1245045

Test 11

Verdict:

input
2000
817 354 1426 168
1163 905 1346 33
631 8 1256 160
1511 1407 998 1021
...

correct output
1787840

user output
1259478

Test 12

Verdict:

input
2000
864 391 493 1719
1414 955 1430 415
739 502 1061 383
56 31 174 1303
...

correct output
1779897

user output
1236611

Test 13

Verdict:

input
2000
1679 692 1203 242
998 850 998 255
1615 1233 1412 1956
162 1991 98 1409
...

correct output
1769951

user output
1214336

Test 14

Verdict:

input
2000
679 2000 2000 0
0 1508 2000 0
0 1408 2000 0
795 2000 2000 0
...

correct output
3105373

user output
754642

Test 15

Verdict:

input
2000
0 927 2000 0
206 2000 2000 0
0 1594 2000 0
0 1546 2000 0
...

correct output
3084266

user output
762245

Test 16

Verdict:

input
2000
0 538 2000 0
105 2000 2000 0
0 885 2000 0
672 2000 2000 0
...

correct output
3086598

user output
770558

Test 17

Verdict:

input
2000
1368 2000 2000 0
411 2000 2000 0
0 833 2000 0
0 1961 2000 0
...

correct output
3104601

user output
764485

Test 18

Verdict:

input
2000
0 818 2000 0
48 2000 2000 0
1277 2000 2000 0
0 1577 2000 0
...

correct output
3115062

user output
750888

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:

input
3
2000 0 0 2000
0 0 1 1
2000 1999 1999 2000

correct output
2002

user output
1

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