結果
| 問題 |
No.2292 Interval Union Find
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-30 10:25:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,443 bytes |
| コンパイル時間 | 825 ms |
| コンパイル使用メモリ | 96,152 KB |
| 最終ジャッジ日時 | 2024-11-15 05:33:03 |
| 合計ジャッジ時間 | 2,574 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:13:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
13 | ios::sync_with_stdio(false);
| ^~~~~~~~~~~~~~~
main.cpp:14:5: error: 'cin' was not declared in this scope
14 | cin.tie(0);
| ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
1 | #include <atcoder/all>
+++ |+#include <iostream>
2 | using namespace std;
main.cpp:42:13: error: 'cout' was not declared in this scope
42 | cout << seg.prod(u, v) << '\n';
| ^~~~
main.cpp:42:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:46:13: error: 'cout' was not declared in this scope
46 | cout << ca[R] - ca[L] + 1 << '\n';
| ^~~~
main.cpp:46:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include <atcoder/all>
using namespace std;
using S = int;
S e(){return 1;}
S op(S lhs, S rhs){return lhs & rhs;}
using F = int;
S mapping(F f, S x){return f == -1 ? x : f;}
F composition(F f, F g){return f == -1 ? g : f;}
F id(){return -1;}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int N, Q, type, u, v, L, R;
cin >> N >> Q;
vector<int> ca(2 * Q + 1);
vector<tuple<int, int, int>> query(Q);
for(int i = 0; i < Q; i++){
cin >> get<0>(query[i]) >> get<1>(query[i]);
if(get<0>(query[i]) != 4) cin >> get<2>(query[i]);
ca[2 * i] = get<1>(query[i]);
ca[2 * i + 1] = get<2>(query[i]);
}
sort(ca.begin(), ca.end());
ca.erase(unique(ca.begin(), ca.end()), ca.end());
atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<int>(ca.size(), 0));
for(int i = 0; i < Q; i++){
tie(type, u, v) = query[i];
u = lower_bound(ca.begin(), ca.end(), u) - ca.begin();
if(v) v = lower_bound(ca.begin(), ca.end(), v) - ca.begin();
if(type <= 2) seg.apply(u, v, 2 - type);
else if(type == 3){
if(u > v) swap(u, v);
cout << seg.prod(u, v) << '\n';
}else{
L = seg.min_left(u, [](int v){return v != 0;} );
R = seg.max_right(u, [](int v){return v != 0;} );
cout << ca[R] - ca[L] + 1 << '\n';
}
}
}