0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:58:48 +00:00

P8470 [Aya Round 1 E] 乙(two)

https://www.luogu.com.cn/record/82833783
This commit is contained in:
Baoshuo Ren 2022-08-07 17:25:23 +08:00
parent 014ab1be4d
commit 83d0904c97
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

50
Luogu/P8470/P8470.cpp Normal file
View File

@ -0,0 +1,50 @@
#include <iostream>
#include <map>
using std::cin;
using std::cout;
const char endl = '\n';
const int dx[] = {0, 1, 0, -1},
dy[] = {1, 0, -1, 0};
int n, x, y;
unsigned long long z;
std::map<int, std::map<int, unsigned long long>> map;
unsigned long long sum;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
while (n--) {
cin >> x >> y >> z;
auto cur = map[x][y]; // 当前值
for (int i = 0; i < 4; i++) {
const int xx = x + dx[i], yy = y + dy[i];
if (!map.count(xx) || !map[xx].count(yy)) continue;
auto t = map[xx][yy];
if (cur < t) {
if (cur + z >= t) {
sum -= (t - cur) * 2;
} else {
sum -= z * 2;
}
}
}
sum += z * 4; // 四个侧面
map[x][y] += z; // 更新高度
cout << sum << endl;
}
return 0;
}