# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
349333 |
2021-01-17T12:18:41 Z |
iANikzad |
Spiral (BOI16_spiral) |
C++14 |
|
1500 ms |
364 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define debug(x) cerr<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long
typedef long long ll;
typedef long double ld;
const int maxn = 5e5 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;
int GET(int x,int y)
{
int mx = max(abs(x), abs(y));
int res = ((2*mx - 1) * (2*mx - 1))%mod;
if(y == mx) res += (mx - x + mx*2);
else if(x == -mx) res += (mx - y + mx*4);
else if(y == -mx) res += (x + mx + mx*6);
else if(x == mx) res += (y + mx);
res %= mod;
return res;
}
int32_t main()
{
FAST;
int n, q;
cin >> n >> q;
while(q--)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int ans = 0;
for(int x = x1;x <= x2; x++) for(int y = y1; y <= y2; y++) ans = (ans + GET(x, y))%mod;
cout << ans << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
413 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
413 ms |
364 KB |
Output is correct |
2 |
Execution timed out |
1577 ms |
364 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1565 ms |
364 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
413 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Execution timed out |
1577 ms |
364 KB |
Time limit exceeded |