제출 #1263321

#제출 시각아이디문제언어결과실행 시간메모리
1263321rtriSpiral (BOI16_spiral)C++20
27 / 100
1596 ms324 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> grid; typedef long long int ll; ll MOD = 1e9 + 7; ll at_poll(ll x, ll y) { y *= -1; if (x == 0 && y == 0) return 1; ll loc = max(abs(x), abs(y)); ll slen = (2 * loc - 1); ll val = slen * slen; if (y == loc) val += 6 * loc + loc + x; else if (x == -loc) val += 4 * loc + loc + y; else if (y == -loc) val += 2 * loc + loc - x; else if (x == loc) val += loc - y; return val; } int main() { int n, q; cin >> n >> q; for (int i = 0; i < q; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; ll ans = 0; for (int x = x1; x <= x2; x++) for (int y = y1; y <= y2; y++) ans = (ans + at_poll(x, y)) % MOD; cout << ans << endl; } 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...