# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
83039 |
2018-11-04T10:45:14 Z |
FedericoS |
Spiral (BOI16_spiral) |
C++14 |
|
156 ms |
63224 KB |
#include <iostream>
using namespace std;
typedef long long int ll;
ll md=1e9+7;
ll N,Q;
ll A[2005][2005];
ll B[2005][2005];
ll C[2005][2005];
ll K=2;
ll a,b,c,d;
ll ans;
int main(){
cin>>N;
A[N][N]=1;
for(ll i=1;i<N+1;i++){
for(ll x=N+i,y=N-i+1;y<N+i+1;y++)
A[x][y]=K++;
for(ll x=N+i-1,y=N+i;x>N-i-1;x--)
A[x][y]=K++;
for(ll x=N-i,y=N+i-1;y>N-i-1;y--)
A[x][y]=K++;
for(ll x=N-i+1,y=N-i;x<N+i+1;x++)
A[x][y]=K++;
}
for(ll i=1;i<2*N+2;i++)
for(ll j=1;j<2*N+2;j++)
B[i][j]=(B[i-1][j]+B[i][j-1]-B[i-1][j-1]+A[i-1][j-1])%md;
cin>>Q;
while(Q--){
cin>>a>>b>>c>>d;
a+=N+1,b+=N+1,c+=N+1,d+=N+1;
ans=(B[c][d]-B[c][b-1]-B[a-1][d]+B[a-1][b-1])%md;
cout<<ans<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
63224 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
63224 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
63224 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
63224 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
156 ms |
63224 KB |
Output isn't correct |