#include<bits/stdc++.h>
using namespace std;
#define mp(x,y) make_pair(x, y)
#define For(i, n) for (int i = 0; i < (int) n; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
int main () {
ll r, c, n, q, m;
cin >> r >> c >> n >> q >> m;
vector<vector<ll> > pref(r + 5, vector<ll>(c + 5, 0)), orig = pref;
For(i, n) {
ll x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
for(int ir = x1; ir < x2; ir++) {
for(int ic = y1; ic < y2; ic++) {
orig [ir][ic] = 1;
}
}
}
For(i, r+1) {
For(j, c+1) {
pref [i + 1][j + 1] = pref [i][j+1] + pref[i+1][j] - pref [i][j] + orig [i][j];
}
}
ll lastres = 0;
For(i, q) {
ll x1_, y1_, x2_, y2_, v;
cin >> x1_ >> y1_ >> x2_ >> y2_ >> v;
ll mod = ((lastres % m) * v) % m;
ll x1 = (x1_ + mod) % m, y1 = (y1_ + mod) % m, x2 = (x2_ + mod) % m, y2 = (y2_ + mod) % m;
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
lastres = pref [x2][y2] - pref [x2][y1] - pref[x1][y2] + pref[x1][y1];
cout << lastres << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4312 KB |
Output is correct |
2 |
Correct |
5 ms |
4300 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4312 KB |
Output is correct |
2 |
Correct |
5 ms |
4300 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
302 ms |
392816 KB |
Output is correct |
5 |
Correct |
326 ms |
392700 KB |
Output is correct |
6 |
Correct |
333 ms |
392896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4312 KB |
Output is correct |
2 |
Correct |
5 ms |
4300 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
302 ms |
392816 KB |
Output is correct |
5 |
Correct |
326 ms |
392700 KB |
Output is correct |
6 |
Correct |
333 ms |
392896 KB |
Output is correct |
7 |
Runtime error |
529 ms |
1048580 KB |
Execution killed with signal 9 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4312 KB |
Output is correct |
2 |
Correct |
5 ms |
4300 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
302 ms |
392816 KB |
Output is correct |
5 |
Correct |
326 ms |
392700 KB |
Output is correct |
6 |
Correct |
333 ms |
392896 KB |
Output is correct |
7 |
Runtime error |
5 ms |
3660 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4312 KB |
Output is correct |
2 |
Correct |
5 ms |
4300 KB |
Output is correct |
3 |
Correct |
5 ms |
4300 KB |
Output is correct |
4 |
Correct |
302 ms |
392816 KB |
Output is correct |
5 |
Correct |
326 ms |
392700 KB |
Output is correct |
6 |
Correct |
333 ms |
392896 KB |
Output is correct |
7 |
Runtime error |
529 ms |
1048580 KB |
Execution killed with signal 9 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
519 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
519 ms |
1048580 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |