№ |
Отправитель |
Задача |
Язык |
Вердикт |
Время |
Память |
Отослано |
Протест. |
|
119487069 |
Дорешивание:
unt311 |
835C
- 35
|
C++17 (GCC 9-64)
|
Неправильный ответ на тесте 3
|
30 мс
|
1772 КБ
|
2021-06-14 23:38:57 |
2021-06-14 23:38:57 |
|
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int n = 101;
int ps[n][n][11];
int a[n][n][11];
bool star[n][n];
int k, q, c;
void solve(int _case){
int t, x1, y1, x2, y2;
cin>>t>>x1>>y1>>x2>>y2;
int _t = t % (c + 1);
cout<<ps[x2][y2][_t] - ps[x1 - 1][y2][_t] - ps[x2][y1 - 1][_t] + ps[x1 - 1][y1 - 1][_t]<<'\n';
}
signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>k>>q>>c;
for(int i{1}; i <= k; ++i){
int x, y;
cin>>x>>y;
cin>>a[x][y][0];
star[x][y] = true;
}
for(int t{}; t <= c; ++t){
for(int i{1}; i < n; ++i){
for(int j{1}; j < n; ++j){
if(star[i][j])
a[i][j][t] = (a[i][j][0] + t) % (c + 1);
ps[i][j][t] = ps[i][j - 1][t] + ps[i - 1][j][t] - ps[i - 1][j - 1][t];
ps[i][j][t] += a[i][j][t];
}
}
}
for(int _case{1}; _case <= q; ++_case){
solve(_case);
}
return 0;
}
Время: ? ms, память: ? КБ