結果
| 問題 | No.3709 Unknown Treasure |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-11 23:08:43 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 1,925 bytes |
| 記録 | |
| コンパイル時間 | 2,297 ms |
| コンパイル使用メモリ | 339,036 KB |
| 実行使用メモリ | 35,584 KB |
| 最終ジャッジ日時 | 2026-09-11 23:09:11 |
| 合計ジャッジ時間 | 26,160 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 TLE * 4 |
ソースコード
#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN
#include __FILE__
using namespace nskr;
struct sg{
vector<int> v;
int w;
sg(int n, int x){
w=1;
while(w<n) w<<=1;
v.resize(w*2, 0);
for(int i=0; i<n;i++) set(i,x);
}
void set(int n, int x){
v[w+n] = x;
int p = ((w+n)>>1);
while(true){
v[p] = v[p*2] + v[p*2+1];
p>>=1;
if(p==0) break;
}
}
int prod(int l, int r){
int k = 1; ll ret = 0;
int i = w+l;
while(l+k <= r){
if(l&k){
ret += v[i];
i++;
i>>=1;
l+=k;
}else{
i>>=1;
}
k<<=1;
}
while(r-l > 0){
if(l+k <= r){
ret += v[i];
i++;
i<<=1;
l+=k;
}else{
i<<=1;
}
k>>=1;
}
return ret;
}
};
int main(void){
ll h, w; cin >> h >> w;
ll n; cin >> n;
vector<sg> s(h,sg(w,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].prod(b,d+1);
if(u == 0) continue;
for(int j=b; j<=d; j++){
s[i].set(j,0);
}
}
}
int i, ans = 0;
rep(i,h){
ans += s[i].v[1];
}
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