結果
問題 | No.230 Splarraay スプラレェーイ |
ユーザー | a_kawashiro |
提出日時 | 2017-12-24 20:30:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 187 ms / 5,000 ms |
コード長 | 3,241 bytes |
コンパイル時間 | 1,800 ms |
コンパイル使用メモリ | 84,444 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-05-09 23:51:16 |
合計ジャッジ時間 | 2,707 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 3 ms
6,940 KB |
testcase_06 | AC | 9 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,944 KB |
testcase_09 | AC | 76 ms
7,424 KB |
testcase_10 | AC | 65 ms
6,940 KB |
testcase_11 | AC | 43 ms
6,940 KB |
testcase_12 | AC | 76 ms
7,552 KB |
testcase_13 | AC | 12 ms
6,940 KB |
testcase_14 | AC | 53 ms
11,520 KB |
testcase_15 | AC | 108 ms
11,392 KB |
testcase_16 | AC | 133 ms
11,520 KB |
testcase_17 | AC | 187 ms
11,648 KB |
testcase_18 | AC | 92 ms
11,520 KB |
testcase_19 | AC | 119 ms
11,392 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | #define GI(i) (scanf("%d",&i)) | ~~~~~~^~~~~~~~~~ main.cpp:90:5: note: in expansion of macro ‘GI’ 90 | GI(N);GI(Q); | ^~ main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | #define GI(i) (scanf("%d",&i)) | ~~~~~~^~~~~~~~~~ main.cpp:90:11: note: in expansion of macro ‘GI’ 90 | GI(N);GI(Q); | ^~ main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | #define GI(i) (scanf("%d",&i)) | ~~~~~~^~~~~~~~~~ main.cpp:95:9: note: in expansion of macro ‘GI’ 95 | GI(x);GI(l);GI(r); | ^~ main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | #define GI(i) (scanf("%d",&i)) | ~~~~~~^~~~~~~~~~ main.cpp:95:15: note: in expansion of macro ‘GI’ 95 | GI(x);GI(l);GI(r); | ^~ main.cpp:20:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | #define GI(i) (scanf("%d",&i)) | ~~~~~~^~~~~~~~~~ main.cpp:95:21: note: in expansion of macro ‘GI’ 95 | GI(x);GI(l);GI(r); | ^~
ソースコード
#include <iostream> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> #include <string> #include <vector> #include <queue> #include <map> #include <set> #include <tuple> #include <algorithm> #include <functional> #include <cstring> #include <limits.h> #define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i) #define REP(i,n) FOR(i,0,n) #define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define SZ(i) ((int)i.size()) #define GI(i) (scanf("%d",&i)) #define GLL(i) (scanf("%lld",&i)) #define GD(i) (scanf("%lf",&i)) #define PB push_back #define MP make_pair #define MT make_tuple #define GET0(x) (get<0>(x)) #define GET1(x) (get<1>(x)) #define GET2(x) (get<2>(x)) #define ALL(X) (X).begin(),(X).end() #define LLMAX (1LL<<60) #define LLMIN -(1LL<<60) #define IMAX (1<<30) #define IMIN -(1<<30) typedef long long LL; using namespace std; class RangeUpdateRangeSum{ public: int sz; vector<LL> node, lazy; RangeUpdateRangeSum(int n) { sz = 1; while (n > sz )sz *= 2; node.assign(2*sz+1,0); lazy.assign(2*sz+1,0); for (int i = 0; i < 2 * sz - 1; i++)lazy[i] = -1; } void lazy_evaluate_node(int k, int l, int r) { if (lazy[k] != -1) { node[k] = lazy[k] * (r - l); if (r - l > 1) { lazy[k * 2 + 1] = lazy[k]; lazy[k * 2 + 2] = lazy[k]; } lazy[k] = -1; } } void update(int a, int b, LL v){ update(a,b,v,0,0,sz); } void update(int a, int b, LL v, int k, int l, int r) { lazy_evaluate_node(k, l, r); if (r <= a || b <= l)return; if (a <= l && r <= b) { lazy[k] = v; lazy_evaluate_node(k, l, r); } else { update(a, b, v, k * 2 + 1, l, (l + r) / 2); update(a, b, v, k * 2 + 2, (l + r) / 2, r); node[k] = node[k * 2 + 1] + node[k * 2 + 2]; } } LL sum(int a, int b){ return sum(a,b,0,0,sz); } LL sum(int a, int b, int k, int l, int r) { lazy_evaluate_node(k, l, r); if (r <= a || b <= l)return 0; if (a <= l && r <= b)return node[k]; LL x = sum(a, b, k * 2 + 1, l, (l + r) / 2); LL y = sum(a, b, k * 2 + 2, (l + r) / 2, r); return x + y; } }; int main(void){ int N,Q; LL A=0,B=0; GI(N);GI(Q); RangeUpdateRangeSum segA(N); RangeUpdateRangeSum segB(N); REP(i,Q){ int x,l,r; GI(x);GI(l);GI(r); r++; if(x==0){ int sA=segA.sum(l,r); int sB=segB.sum(l,r); if(sA<sB) B+=sB; else if(sA>sB) A+=sA; }else if(x==1){ segA.update(l,r,1); segB.update(l,r,0); }else if(x==2){ segA.update(l,r,0); segB.update(l,r,1); } } A+=segA.sum(0,N); B+=segB.sum(0,N); printf("%lld %lld\n",A,B); return 0; }