Code Submission Evaluation System Login

BOI 2016, day 1

Start:2016-05-12 09:00:00
End:2016-05-12 14:00:00
 

Tasks | Scoreboard | Statistics


CSES - BOI 2016, day 1 - Results
History
2016-05-12 13:38:5227
2016-05-12 13:18:3912
2016-05-12 13:11:1712
2016-05-12 13:07:1412
2016-05-12 13:05:2112
2016-05-12 12:36:1112
2016-05-12 12:24:400
2016-05-12 12:20:310
2016-05-12 12:18:010
Task:Spiral
Sender:elgun1999
Submission time:2016-05-12 13:38:52
Language:C++
Status:READY
Score:27

Feedback

groupverdictscore
#1ACCEPTED12
#2ACCEPTED15
#3WRONG ANSWER0
#4WRONG ANSWER0
#5WRONG ANSWER0

Test results

testverdicttime (s)group
#1ACCEPTED0.34 / 1.501details
#2ACCEPTED0.06 / 1.502details
#3WRONG ANSWER0.05 / 1.503details
#4WRONG ANSWER0.06 / 1.504details
#5WRONG ANSWER0.05 / 1.505details

Code

#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

ll n, q, a[5001][5001], k = 1, x = 1, y, X, Y;

int main()
{
    cin >> n >> q;
    if (n <= 1000) {
    a[n][n] = x++;
    while(x < (2 * n + 1) * (2 * n + 1)) {
        for (int i = n + k - 1; i >= n - k; i--)
            a[i][n + k] = x++;
        for (int i = n + k - 1; i >= n - k; i--)
            a[n - k][i] = x++;
        for (int i = n - k + 1; i <= n + k; i++)
            a[i][n - k] = x++;
        for (int i = n - k + 1; i <= n + k; i++)
            a[n + k][i] = x++;
        k++;
    }
    }
    while(q--) {
        cin >> y >> x >> Y >> X;
        y += n, Y += n;
        x += n, X += n;
        x = 2 * n - x, X = 2 * n - X;
        if (n <= 1000) {
        ll c = 0;
        for (int i = min(x, X); i <= max(x, X); i++)
            for (int j = min(y, Y); j <= max(y, Y); j++)
                c = (c + a[i][j]) % mod;
            cout << c << endl;
            continue;
        }
        k = max(abs(n - x), abs(n - y));

        if (!k) {
            cout << 1 << endl;
            continue;
        }
        X = k;
        k--;
        k = (2 * k + 1);
        k *= k;
        k %= mod;
        if (y == n + X && x < n + X) {
            k += n + X - x;
            k %= mod;
            cout << k << endl;
            continue;
        }
        k += X * 2;
        k %= mod;
        if (x == n - X) {
            k += n + X - y;
            k %= mod;
            cout << k << endl;
            continue;
        }
        k += X * 2;
        k %= mod;
        if (y == n - X) {
            k += x - (n - X);
            k %= mod;
            cout << k << endl;
            continue;
        }
        k += X * 2;
        k %= mod;
        k += y - (n - X);
        k %= mod;
        cout << k << endl;
    }

    return 0;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1000 100
-709 0 1000 123
-621 -1000 -102 -435
-602 -560 276 -356
-945 -590 0 -468
...
view   save

correct output
788057008
633127082
507903329
53165899
558016315
...
view   save

user output
788057008
633127082
507903329
53165899
558016315
...
view   save

Test 2

Group: 2

Verdict: ACCEPTED

input
1000000000 100
181053719 1000000000 181053719...
view   save

correct output
818946492
750635163
193830026
660632411
46072376
...
view   save

user output
818946492
750635163
193830026
660632411
46072376
...
view   save

Test 3

Group: 3

Verdict: WRONG ANSWER

input
100000 100
-88233 -87279 -49871 52277
-86645 -7997 48948 30702
-79916 -36210 -21257 -16821
0 57331 93163 100000
...
view   save

correct output
986592951
708386765
85336595
18263594
32233727
...
view   save

user output
140424452
29518533
546384176
147316823
919645860
...
view   save

Test 4

Group: 4

Verdict: WRONG ANSWER

input
1000000000 100
1 1 21134200 719983102
1 1 929463279 1000000000
1 1 68450838 1
1 1 84417340 297177199
...
view   save

correct output
695961158
957360176
137575768
522232140
58884045
...
view   save

user output
3
3
3
3
3
...
view   save

Test 5

Group: 5

Verdict: WRONG ANSWER

input
1000000000 100
-857489445 -1000000000 -432836...
view   save

correct output
902627632
581519884
819269364
857298983
278402948
...
view   save

user output
142510738
147813673
117282932
17826800
623833082
...
view   save