結果
| 問題 |
No.2292 Interval Union Find
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2023-05-05 22:31:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,477 bytes |
| コンパイル時間 | 1,307 ms |
| コンパイル使用メモリ | 120,084 KB |
| 最終ジャッジ日時 | 2025-02-12 18:45:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 1 |
| other | AC * 11 RE * 33 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/lazysegtree>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
const int inf = 1e9;
int op(int x, int y){
return min(x, y);
}
int e(){
return inf;
}
int id(){
return -1;
}
int mapping(int f, int x){
if(f == id()) return x;
return f;
}
int composition(int f, int g){
if(f == id()) return g;
return f;
}
using Seg = atcoder::lazy_segtree<int, op, e, int, mapping, composition, id>;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n, q; cin >> n >> q;
Seg seg(vector<int>(n-1, 0));
while(q--){
int t; cin >> t;
if(t == 1){
int l, r; cin >> l >> r; l--; r--;
seg.apply(l, r, 1);
}else if(t == 2){
int l, r; cin >> l >> r; l--; r--;
seg.apply(l, r, 0);
}else if(t == 3){
int u, v; cin >> u >> v; u--; v--;
if(u > v) swap(u, v);
if(seg.prod(u, v) == 0){
cout << 0 << endl;
}else{
cout << 1 << endl;
}
}else{
int v; cin >> v; v--;
auto g = [&](int x){
return x >= 1;
};
int r = seg.max_right(v, g);
int l = seg.min_left(v, g);
cout << r-l+1 << endl;
}
}
}
milanis48663220