結果
| 問題 |
No.230 Splarraay スプラレェーイ
|
| コンテスト | |
| ユーザー |
yuruhiya
|
| 提出日時 | 2021-04-12 20:44:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 642 bytes |
| コンパイル時間 | 1,247 ms |
| コンパイル使用メモリ | 104,280 KB |
| 最終ジャッジ日時 | 2025-01-20 16:19:25 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:9: error: ‘cin’ was not declared in this scope
14 | cin>>n>>q;
| ^~~
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:30:9: error: ‘cout’ was not declared in this scope
30 | cout<<a+A.all_prod().v<<' '<<b+B.all_prod().v<<'\n';
| ^~~~
main.cpp:30:9: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
ソースコード
#include <atcoder/all>
using namespace std;
using ll = long long;
struct S { ll v,s; };
S op(S a,S b) { return {a.v+b.v,a.s+b.s}; }
S e() { return {0,0}; }
S ma(ll f,S x) { return {f<0?x.v:f*x.s,x.s}; }
ll co(ll f,ll g) { return f==-1?g:f; }
ll id() { return -1; }
int main() {
int n,q;
cin>>n>>q;
atcoder::lazy_segtree<S,op,e,ll,ma,co,id> A(vector(n,S{0,1}));
auto B=A;
ll a=0,b=0;
for (; q--;) {
int x,l,r;
cin>>x>>l>>r,r++;
if (x) {
A.apply(l,r,!~-x);
B.apply(l,r,+~-x);
} else {
ll x=A.prod(l,r).v,y=B.prod(l,r).v;
if (x>y) a+=x;
if (x<y) b+=y;
}
}
cout<<a+A.all_prod().v<<' '<<b+B.all_prod().v<<'\n';
}
yuruhiya