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 12:30:2927
2016-05-12 12:26:0912
2016-05-12 12:22:2712
2016-05-12 12:22:120
2016-05-12 12:19:0512
2016-05-12 12:01:1412
Task:Spiral
Sender:doge
Submission time:2016-05-12 12:01:14
Language:C++
Status:READY
Score:12

Feedback

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

Test results

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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:25:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n); assert(n <= 1000);
                 ^
input/code.cpp:39:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
                 ^
input/code.cpp:42:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                                        ^

Code

#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << " = " << x << endl;
typedef long long LL;

const int N 	= (int) 3e3 + 10;
const int P 	= (int) 1e9 + 7;
const int DX[4]	= {0, 1, 0, -1};
const int DY[4] = {1, 0, -1, 0};
int n, q, a[N][N];
LL s[N][N];

LL Get(int x1, int y1, int x2, int y2) {
	x1 += n + 1; y1 += n + 1;
	x2 += n + 1; y2 += n + 1;
	return ((s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]) % P + P) % P;
}

int main() {
#ifdef LOCAL
	freopen("Data.inp", "r", stdin);
	freopen("Data.out", "w", stdout);
#endif

	scanf("%d", &n); assert(n <= 1000);
	for (int i = n + 1, j = n + 1, d = 1, p = 0, k = 0, v = 0; v + 1 < (2 * n + 1) * (2 * n + 1); ) {
		for (int z = 1; z <= d; ++z) {
			a[i][j] = ++v;
			i += DX[k]; j += DY[k];
		}
		if (p == d) d++; else p = d;
		k = (k + 1) % 4;
	}

	for (int i = 1; i <= 2 * n + 1; ++i)
		for (int j = 1; j <= 2 * n + 1; ++j) 
			s[i][j] = (s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j]) % P;

	scanf("%d", &q);
	while (q--) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
		printf("%lld\n", Get(x1, y1, x2, y2));
	}
	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)

Error:
code: input/code.cpp:25: int main(): Assertion `n <= 1000' failed.

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)

Error:
code: input/code.cpp:25: int main(): Assertion `n <= 1000' failed.

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)

Error:
code: input/code.cpp:25: int main(): Assertion `n <= 1000' failed.

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)

Error:
code: input/code.cpp:25: int main(): Assertion `n <= 1000' failed.