# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
32266 |
2017-10-06T00:34:48 Z |
dqhungdl |
Spiral (BOI16_spiral) |
C++14 |
|
36 ms |
33580 KB |
#include <bits/stdc++.h>
using namespace std;
int n,T;
int64_t a[2005][2005];
void Sub1()
{
a[n+1][n+1]=1;
int ii=1,jj=0,Count=1;
for(int i=1;i<=n;i++)
{
while(jj<=i)
{
a[ii+n+1][jj+n+1]=++Count;
jj++;
}
jj--;
ii--;
while(ii>=-i)
{
a[ii+n+1][jj+n+1]=++Count;
ii--;
}
ii++;
jj--;
while(jj>=-i)
{
a[ii+n+1][jj+n+1]=++Count;
jj--;
}
jj++;
ii++;
while(ii<=i)
{
a[ii+n+1][jj+n+1]=++Count;
ii++;
}
}
for(int i=1;i<=2*n+1;i++)
for(int j=1;j<=2*n+1;j++)
a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
int u1,v1,u2,v2;
while(T--)
{
cin>>u1>>v1>>u2>>v2;
u1+=n+1;
v1+=n+1;
u2+=n+1;
v2+=n+1;
cout<<a[u2][v2]-a[u1-1][v2]-a[u2][v1-1]+a[u1-1][v1-1]<<"\n";
}
}
int main()
{
ios_base::sync_with_stdio(false);
//freopen("SPIRAL.INP","r",stdin);
cin>>n>>T;
if(n<=1000)
Sub1();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
33580 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
33580 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
33580 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
33580 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
33580 KB |
Output isn't correct |