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 11:14:4412
2016-05-12 10:56:290
2016-05-12 10:44:090
2016-05-12 10:43:050
2016-05-12 10:30:150
2016-05-12 10:29:120
2016-05-12 10:22:510
2016-05-12 10:22:30
2016-05-12 10:10:220
2016-05-12 10:07:360
2016-05-12 10:07:12
Task:Spiral
Sender:ivoka2001
Submission time:2016-05-12 11:14:44
Language:C++
Status:READY
Score:12

Feedback

groupverdictscore
#1ACCEPTED12
#2RUNTIME ERROR0
#3RUNTIME ERROR0
#4RUNTIME ERROR0
#5RUNTIME ERROR0

Test results

testverdicttime (s)group
#1ACCEPTED0.12 / 1.501details
#2RUNTIME ERROR0.13 / 1.502details
#3RUNTIME ERROR0.14 / 1.503details
#4RUNTIME ERROR0.14 / 1.504details
#5RUNTIME ERROR0.14 / 1.505details

Code

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int mod = 1e9 + 7, maxN = 1005;

long long n, current = 2, current_i, current_j = 1, pos = 2, current_sum_row, current_sum_col, q, x1, x2, yy1, y2, current_ans, board[2 * maxN  + 5][2 * maxN + 5], partial_sums_rows[2 * maxN + 5][2 * maxN + 5], partial_sums_cols[2 * maxN + 5][2 * maxN + 5];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    board[n + 1][n + 1] = 1;
    while(current != (2 * n + 1) * (2 * n + 1) + 1)
    {
        board[current_i + n + 1][current_j + n + 1] = current++;

        if(pos == 1)
        {
            if(board[current_i + n + 1][current_j - 1 + n + 1] == 0)
            {
                current_j--;
                pos = 4;
            }
            else current_i--;
        }
        else if(pos == 2)
        {
            if(board[current_i - 1 + n + 1][current_j + n + 1] == 0)
            {
                current_i--;
                pos = 1;
            }
            else current_j++;
        }
        else if(pos == 3)
        {
            if(board[current_i + n + 1][current_j + 1 + n + 1] == 0)
            {
                current_j++;
                pos = 2;
            }
            else current_i++;
        }
        else
        {
            if(board[current_i + 1 + n + 1][current_j + n + 1] == 0)
            {
                current_i++;
                pos = 3;
            }
            else current_j--;
        }
    }

    //cout<<board[2 * n + 1][2 * n + 1]<<endl;

    for(long long i = -n; i <= n; i++)
    {
        current_sum_row = 0;
        current_sum_col = 0;
        for(long long j = -n; j <= n; j++)
        {
            current_sum_row = (current_sum_row + board[i + n + 1][j + n + 1]) % mod;
            current_sum_col = (current_sum_col + board[j + n + 1][i + n + 1]) % mod;

            partial_sums_rows[-i + n + 1][j + n + 1] = current_sum_row;
            partial_sums_cols[-j + n + 1][i + n + 1] = current_sum_col;
        }
    }

    cin>>q;
    for(long long i = 0; i < q; i++)
    {
        current_ans = 0;
        cin>>x1>>yy1>>x2>>y2;

        if(x2 - x1 <= y2 - yy1)
        {
            for(long long j = x1; j <= x2; j++)
            {
                current_ans = (current_ans + (partial_sums_cols[yy1 + n + 1][j + n + 1] - partial_sums_cols[y2 + 1 + n + 1][j + n + 1] >= 0 ? partial_sums_cols[yy1 + n + 1][j + n + 1] - partial_sums_cols[y2 + 1 + n + 1][j + n + 1] : partial_sums_cols[yy1 + n + 1][j + n + 1] - partial_sums_cols[y2 + 1 + n + 1][j + n + 1] + mod)) % mod;
                //cout<<partial_sums_cols[yy1 + n + 1][j + n + 1]<<" "<<partial_sums_cols[y2 + 1 + n + 1][j + n + 1]<<endl;
            }
        }
        else
        {
            for(long long j = yy1; j <= y2; j++)
            {
                current_ans = (current_ans + (partial_sums_rows[j + n + 1][x2 + n + 1] - partial_sums_rows[j + n + 1][x1 - 1 + n + 1] >= 0 ? partial_sums_rows[j + n + 1][x2 + n + 1] - partial_sums_rows[j + n + 1][x1 - 1 + n + 1] : partial_sums_rows[j + n + 1][x2 + n + 1] - partial_sums_rows[j + n + 1][x1 - 1 + n + 1] + mod)) % mod;
            }
        }

        cout<<current_ans<<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
-106 -809 235 -277
-654 -317 975 1
42 -250 271 80
-537 -341 307 685
-939 -1000 67 429
-737 -743 -206 -656
-244 -816 210 -265
-948 -306 -693 149
1000 -230 1000 266
-1 146 497 780
1 -653 295 536
-629 413 235 505
-1000 -163 -1000 -127
-33 -773 128 29
-895 0 324 648
...
view   save

correct output
788057008
633127082
507903329
53165899
558016315
302089138
566211035
559423498
252507519
337514610
408751067
11314517
986518436
749615506
770971645
659417332
148042402
377036107
695769426
139996789
...
view   save

user output
788057008
633127082
507903329
53165899
558016315
302089138
566211035
559423498
252507519
337514610
408751067
11314517
986518436
749615506
770971645
659417332
148042402
377036107
695769426
139996789
...
view   save

Test 2

Group: 2

Verdict: RUNTIME ERROR

input
1000000000 100
181053719 1000000000 181053719...
852751643 863389570 852751643 ...
-161213342 -447073611 -1612133...
813819781 -140986437 813819781...
-268931454 1 -268931454 1
-535129439 664254541 -53512943...
-37958808 536286414 -37958808 ...
570795830 -434946577 570795830...
405557765 652154349 405557765 ...
217542840 879737653 217542840 ...
-8797270 0 -8797270 0
263406926 -103702080 263406926...
417673370 -1 417673370 -1
-618520914 -724183720 -6185209...
-845795672 376533093 -84579567...
325062284 1 325062284 1
598762221 -430223124 598762221...
240779920 -225435228 240779920...
540964704 -76817080 540964704 ...
...
view   save

correct output
818946492
750635163
193830026
660632411
46072376
472803047
812702745
911600992
712194929
656239841
844441902
822425230
890978307
121806251
534620131
983366131
922448146
929751481
1520635
549597234
...
view   save

user output
(empty)
view   save

Test 3

Group: 3

Verdict: RUNTIME ERROR

input
100000 100
-88233 -87279 -49871 52277
-86645 -7997 48948 30702
-79916 -36210 -21257 -16821
0 57331 93163 100000
44248 -92086 82069 33876
-94630 25007 -25590 98962
16155 -5755 96544 62759
-81488 -26648 23 100000
-14958 56727 93378 89262
8115 -61830 100000 14245
81406 -71848 89340 -27273
-21732 -3446 0 90611
-29732 -31333 -17581 88824
-49910 -100000 75765 60308
-99934 99821 -2437 100000
-30488 3497 27202 85753
-96429 -60310 94121 -52638
-91077 -72776 -55352 0
-60349 -93167 -22305 -70442
...
view   save

correct output
986592951
708386765
85336595
18263594
32233727
191927838
917012013
68207304
680109056
161693316
718423685
402706528
445400315
482305558
902547162
575661103
458292319
248089294
568361776
369103934
...
view   save

user output
(empty)
view   save

Test 4

Group: 4

Verdict: RUNTIME ERROR

input
1000000000 100
1 1 21134200 719983102
1 1 929463279 1000000000
1 1 68450838 1
1 1 84417340 297177199
1 1 1 343367274
1 1 124752051 466376574
1 1 881274458 333485384
1 1 1 639843287
1 1 218885316 41069224
1 1 389032543 1
1 1 559995242 339166021
1 1 1000000000 1
1 1 576960949 906365100
1 1 1 665174609
1 1 479125748 1
1 1 863672278 963679556
1 1 167501216 1000000000
1 1 601316864 722654796
1 1 739729791 880627974
...
view   save

correct output
695961158
957360176
137575768
522232140
58884045
406010456
146562569
456690551
167395515
484286023
395206507
999999566
822116832
848601421
771498811
187752764
103974960
284245539
174771858
698363351
...
view   save

user output
(empty)
view   save

Test 5

Group: 5

Verdict: RUNTIME ERROR

input
1000000000 100
-857489445 -1000000000 -432836...
81977033 -740250254 605214029 ...
681633641 -1 786755036 1367416...
613219620 -629478605 763915005...
2964572 244317647 601041223 99...
-196156852 -128320437 69180975...
-542221994 -159095881 -2993968...
-297670401 305316465 207760864...
-647927334 -75065196 -1 301899...
-740735184 -979789736 1 -81317...
-893563915 -937860292 -7315639...
-150493935 -53307647 408566258...
4971883 120690836 643069370 70...
-899606935 -162385187 44595688...
74629300 517384780 458554953 6...
-1 417955698 802239354 7895247...
-860356476 -1000000000 -317982...
-807742787 -100142044 91420967...
-641658816 1142760 -29777797 7...
...
view   save

correct output
902627632
581519884
819269364
857298983
278402948
138389570
382251480
497385669
179802934
291456937
561433345
100042259
624201364
527261545
383179762
427359341
385615799
741162504
982984746
422953981
...
view   save

user output
(empty)
view   save