제출 #349333

#제출 시각아이디문제언어결과실행 시간메모리
349333iANikzadSpiral (BOI16_spiral)C++14
27 / 100
1577 ms364 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...