#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const long long mod = 1e9+7;
const int N = 5007;
int main()
{
int n,q;
cin>>n>>q;
for(int i=1;i<=q;++i){
long long x,y;
cin>>x>>y>>x>>y;
long long r=max(abs(x),abs(y));
long long h=r+r+1;
h%=mod;
long long sz=h*h;
sz%=mod;
if(y==-r){
cout<<(sz-(r-x)+mod+mod)%mod<<endl;
}
else{
sz-=r;
sz-=r;
sz+=mod;
sz+=mod;
sz%=mod;
if(x==-r){
cout<<(sz-(y+r)+mod+mod)%mod<<endl;
}
else{
sz-=r;
sz-=r;
sz+=mod;
sz+=mod;
sz%=mod;
if(y==r){
cout<<(sz-(x+r)+mod+mod)%mod<<endl;
}
else{
sz-=r;
sz-=r;
sz+=mod;
sz+=mod;
sz%=mod;
cout<<(sz-(r-y)+mod+mod)%mod<<endl;
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
488 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |