CSES - BOI 2016, day 1 - Results
 Task: Spiral Sender: phobos Submission time: 2016-05-12 09:58:35 Language: C++ Status: READY Result: 15
Feedback
groupverdictscore
#10
#2ACCEPTED15
#30
#40
#50
Test results
testverdicttimegroup
#10.05 s1details
#2ACCEPTED0.06 s2details
#30.05 s3details
#40.06 s4details
#50.06 s5details

### Compiler report

```input/code.cpp: In function 'int main()':
input/code.cpp:38:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &n, &q);
^
input/code.cpp:41:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
^
input/code.cpp: In function 'long long int solve(long long int, long long int, long long int, long long int)':
input/code.cpp:34:9: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
return ret;
^```

### Code

```#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iostream>
#define ll long long
using namespace std;
ll n, q;
const ll MOD = 1e9+7;

ll solve(ll x1, ll y1, ll x2, ll y2) {
ll x = x1, y = y1, ret;
if (x == y && y == 0) ret = 1;
else if (fabs(x) == fabs(y)) {
ll m = fabs(x);
if (x > 0 && y > 0) ret = ((2*m-1)*(2*m-1)+2*m)%MOD;
if (x < 0 && y > 0) ret = ((2*m-1)*(2*m-1)+4*m)%MOD;
if (x < 0 && y < 0) ret = ((2*m-1)*(2*m-1)+6*m)%MOD;
if (x > 0 && y < 0) ret = ((2*m-1)*(2*m-1)+8*m)%MOD;
}
else {
if (fabs(x) > fabs(y)) {
ll m = fabs(x);
if (x > 0) ret = ((2*m-1)*(2*m-1)+m+y)%MOD;
else ret = ((2*m-1)*(2*m-1)+5*m-y)%MOD;
}
else {
ll m = fabs(y);
if (y > 0) ret = ((2*m-1)*(2*m-1)+3*m-x)%MOD;
else ret = ((2*m-1)*(2*m-1)+7*m+x)%MOD;
}
}
return ret;
}

int main() {
scanf("%lld%lld", &n, &q);
for (int i = 0; i < q; i++) {
ll x1, y1, x2, y2;
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
printf("%lld\n", solve(x1, y1, x2, y2));
}
return 0;
}```

### Test details

#### Test 1

Group: 1

Verdict:

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

correct output
788057008
633127082
507903329
53165899
558016315
...

user output
2011434
4002380
1450779
3573636
2620246
...

#### Test 2

Group: 2

Verdict: ACCEPTED

input
1000000000 100
181053719 1000000000 181053719...

correct output
818946492
750635163
193830026
660632411
46072376
...

user output
818946492
750635163
193830026
660632411
46072376
...

#### Test 3

Group: 3

Verdict:

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

correct output
986592951
708386765
85336595
18263594
32233727
...

user output
140424452
29518533
546384176
147316823
919645860
...

#### Test 4

Group: 4

Verdict:

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

correct output
695961158
957360176
137575768
522232140
58884045
...

user output
3
3
3
3
3
...

#### Test 5

Group: 5

Verdict:

input
1000000000 100
-857489445 -1000000000 -432836...

correct output
902627632
581519884
819269364
857298983
278402948
...

user output
142510738
147813673
117282932
17826800
623833082
...