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:26:09
Language:C++
Status:READY
Score:12

Feedback

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

Test results

testverdicttime (s)group
#1ACCEPTED0.08 / 1.501details
#2WRONG ANSWER0.05 / 1.502details
#3WRONG ANSWER0.05 / 1.503details
#4WRONG ANSWER0.05 / 1.504details
#5WRONG ANSWER0.06 / 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);
                 ^
input/code.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
                  ^
input/code.cpp:43:41: 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);
                                         ^
input/code.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
                  ^
input/code.cpp:51:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%

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);
	if (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));
		}
	}
	else {
		scanf("%d", &q);
		while (q--) {
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
			int x = x1, y = y1;
			int k = max(abs(x), abs(y));
			LL ans, s = (2 * k - 1ll) * (2 * k - 1ll) % P;
			if (y == k && -k + 1 <= x && x <= k)	ans = s + x + k; else
			if (x == k && -k <= y && y <= k - 1)	ans = s + 3 * k - y; else
			if (y == -k && -k <= x && x <= k - 1)	ans = s + 5 * k - x; else
			ans = s + 6 * k + y + k;
			if (k == 0) ans = 1;
			printf("%lld\n", ans % P);
		}
	}
	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: WRONG ANSWER

input
1000000000 100
181053719 1000000000 181053719...
view   save

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

user output
-476020783
-544332112
-101137242
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
847543477
852846412
117282932
722859539
623833082
...
view   save