結果
| 問題 | No.255 Splarrraaay スプラーレェーーイ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-30 22:37:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,178 bytes |
| 記録 | |
| コンパイル時間 | 1,044 ms |
| コンパイル使用メモリ | 102,016 KB |
| 最終ジャッジ日時 | 2024-06-30 06:43:50 |
| 合計ジャッジ時間 | 2,445 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
21 | ios::sync_with_stdio(false);
| ^~~~~~~~~~~~~~~
main.cpp:22:5: error: 'cin' was not declared in this scope
22 | 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:64:9: error: 'cout' was not declared in this scope
64 | cout << score[i] << (i + 1 == 5 ? '\n' : ' ');
| ^~~~
main.cpp:64:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll MOD = 1'000'000'000'000'000'009ll;
using S = pair<ll, ll>;
using F = pair<ll, ll>;
S e(){return S({0, 0});}
S op(S l, S r) { return make_pair(l.first + r.first, l.second + r.second); }
S mapping(F f, S x) { return make_pair(x.first * f.first + x.second * f.second, x.second); }
F composition(F f, F g) { return make_pair(f.first * g.first, g.second * f.first + f.second); }
F id() {return make_pair(1, 0); }
void add(ll &x, ll y){
x += y;
while(x >= MOD)x -= MOD;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll N, l, r;
int Q, cmd;
cin >> N >> Q;
vector<tuple<int, ll, ll>> query(Q);
vector<ll> ca = {0, N};
for(int i = 0; i < Q; i++){
cin >> cmd >> l >> r;
r++;
query[i] = make_tuple(cmd, l, r);
ca.push_back(l);
ca.push_back(r);
}
sort(ca.begin(), ca.end());
ca.erase(unique(ca.begin(), ca.end()), ca.end());
vector<S> temp(ca.size(), make_pair(0, 0));
for(int i = 0; i + 1 < ca.size(); i++){
temp[i].second = ca[i + 1] - ca[i];
}
vector<lazy_segtree<S, op, e, F, mapping, composition, id>> seg(5, lazy_segtree<S, op, e, F, mapping, composition, id>(temp));
array<ll, 5> score{}, temp2{};
for(int i = 0; i < Q; i++){
tie(cmd, l, r) = query[i];
l = lower_bound(ca.begin(), ca.end(), l) - ca.begin();
r = lower_bound(ca.begin(), ca.end(), r) - ca.begin();
if(cmd == 0){
for(int i = 0; i < 5; i++){
temp2[i] = seg[i].prod(l, r).first;
}
auto it = max_element(temp2.begin(), temp2.end());
if(count(temp2.begin(), temp2.end(), *it) >= 2)continue;
add(score[it - temp2.begin()], *it);
}else{
cmd--;
for(int i = 0; i < 5; i++){
if(i == cmd)seg[i].apply(l, r, {1, 1});
else seg[i].apply(l, r, {0, 0});
}
}
}
for(int i = 0; i < 5; i++){
add(score[i], seg[i].all_prod().first);
cout << score[i] << (i + 1 == 5 ? '\n' : ' ');
}
}