結果
| 問題 | No.3709 Unknown Treasure |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-11 21:32:14 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 67 ms / 2,000 ms |
| + 286µs | |
| コード長 | 1,481 bytes |
| 記録 | |
| コンパイル時間 | 2,014 ms |
| コンパイル使用メモリ | 336,096 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2026-09-11 21:32:29 |
| 合計ジャッジ時間 | 5,220 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <class T> struct imos2D{
int h, w;
std::vector<std::vector<T>> dat;
imos2D(int H, int W) : h(H), w(W), dat(H + 1, std::vector<T>(W + 1, 0)) {}
void add(int ly, int lx, int ry, int rx, T v){
assert(0 <= ly && ly <= ry && ry <= h);
assert(0 <= lx && lx <= rx && rx <= w);
dat[ry][rx] += v;
dat[ly][rx] -= v;
dat[ry][lx] -= v;
dat[ly][lx] += v;
}
void build(){
for(int i = 0; i <= h; i++) {
for(int j = 1; j <= w; j++) {
dat[i][j] += dat[i][j - 1];
}
}
for(int i = 0; i <= w; i++) {
for(int j = 1; j <= h; j++) {
dat[j][i] += dat[j - 1][i];
}
}
}
const std::vector<T>& operator[](int y) const {
assert(0 <= y && y < h);
return dat[y];
}
std::vector<T>& operator[](int y) {
assert(0 <= y && y < h);
return dat[y];
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int h, w, n;
cin >> h >> w >> n;
imos2D<int> imos(h, w);
for(int i = 0; i < n; i++){
int ly, lx, ry, rx;
cin >> ly >> lx >> ry >> rx;
ly--, lx--;
imos.add(ly, lx, ry, rx, 1);
}
imos.build();
int ans = 0;
for(int y = 0; y < h; y++){
for(int x = 0; x < w; x++){
ans += imos[y][x] == 0;
}
}
cout << ans << '\n';
}