結果
| 問題 | No.3709 Unknown Treasure |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-11 23:17:37 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,800 bytes |
| 記録 | |
| コンパイル時間 | 2,241 ms |
| コンパイル使用メモリ | 337,840 KB |
| 実行使用メモリ | 34,816 KB |
| 最終ジャッジ日時 | 2026-09-11 23:18:18 |
| 合計ジャッジ時間 | 21,771 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 TLE * 2 |
ソースコード
#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN
#include __FILE__
using namespace nskr;
struct segment_tree {
int n;
vector<int> node;
segment_tree(int n) : n(n), node(n<<1, 0) {} // 初期値が0になりました
// i番目の要素そのものにアクセスできる機能をつけました
int operator[](int i) { return node[i + n]; }
void set(int i, int x) {
node[i += n] = x;
while (i >>= 1) node[i] = node[i<<1|0] + node[i<<1|1]; // 和になりました
}
int fold(int l, int r) {
int res = 0; // 初期値が0になりました
for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
if (l & 1) res = res + node[l++]; // 和になりました
if (r & 1) res = node[--r] + res; // 和になりました
}
return res;
}
};
int main(void){
ll h, w; cin >> h >> w;
ll n; cin >> n;
vector<segment_tree> s(h,segment_tree(w));
int i,j;
rep(i,h) rep(j,w) s[i].set(j,1);
for(;n--;){
int a,b,c,d; cin >> a >> b >> c >> d;
a--;b--;c--;d--;
for(int i=a; i<=c; i++){
int u = s[i].fold(b,d+1);
if(u == 0) continue;
for(int j=b; j<=d; j++){
s[i].set(j,0);
}
}
}
int ans = 0;
rep(i,h){
ans += s[i].fold(0,w);
}
cout << ans << "\n";
}
#else
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld= long double;
#define rep(i,n) for(i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
namespace nskr{}
int randint(int a, int b){
static mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> dist(a,b);
return dist(gen);
}
#endif