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
...
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: RUNTIME ERROR

input
1000000000 100
181053719 1000000000 181053719...
view   save

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

user output
(empty)

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
...
view   save

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

user output
(empty)

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
...
view   save

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

user output
(empty)

Test 5

Group: 5

Verdict: RUNTIME ERROR

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

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

user output
(empty)