結果

問題 No.255 Splarrraaay スプラーレェーーイ
コンテスト
ユーザー omochanal
提出日時 2018-11-21 02:38:37
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 4,688 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,044 ms
コンパイル使用メモリ 169,544 KB
最終ジャッジ日時 2026-05-30 11:20:11
合計ジャッジ時間 1,966 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In instantiation of 'void Debug(FIRST, REST ...) [with FIRST = std::vector<long long int>; REST = {}]':
main.cpp:26:22:   recursively required from 'void Debug(FIRST, REST ...) [with FIRST = const char*; REST = {std::vector<long long int, std::allocator<long long int> >}]'
   26 |         cout<<arg<<" ";Debug(rest...);}
      |                        ~~~~~^~~~~~~~~
main.cpp:26:22:   required from 'void Debug(FIRST, REST ...) [with FIRST = int; REST = {const char*, std::vector<long long int, std::allocator<long long int> >}]'
main.cpp:98:3:   required from here
   13 | #define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:26:13: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::vector<long long int>')
   26 |         cout<<arg<<" ";Debug(rest...);}
      |         ~~~~^~~~~
main.cpp:26:13: note: there are 77 candidates
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/istream:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/sstream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/complex:50,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ccomplex:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:133,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:116:7: note: candidate 1: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  116 |       operator<<(__

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000000000000000ll + 9;
const ll inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

vector<ll> vx;

struct segtree { // this is piece of shit. use BIT
	int n; vl sum, lazy, mul;
	void init(int mx) {
		n = 1;
		while(n < mx) n *= 2;
		sum = vl(n * 2, 0);
		mul = vl(n * 2, 1);
		lazy = vl(n * 2, 0);
	}
	segtree(int mx = 0) { init(mx); }
	inline void lazy_eval(int k, int l, int r) {
		int m = (l + r) / 2;
		if(mul[k] != 1 || lazy[k]) {
			MUL(sum[k * 2 + 1], mul[k]);//if range_min, erase (m - l)
			ADD(sum[k * 2 + 1], (vx[m] - vx[l]) * lazy[k]);
			MUL(mul[k * 2 + 1], mul[k]);
			MUL(lazy[k * 2 + 1], mul[k]);
			ADD(lazy[k * 2 + 1], lazy[k]);
			MUL(sum[k * 2 + 2], mul[k]);//if range_min, erase (m - l)
			ADD(sum[k * 2 + 2], (vx[r] - vx[m]) * lazy[k]);
			MUL(mul[k * 2 + 2], mul[k]);
			MUL(lazy[k * 2 + 2], mul[k]);
			ADD(lazy[k * 2 + 2], lazy[k]);
			mul[k] = 1;
			lazy[k] = 0;
		}
	}
	void app(int a, int b, ll s, int k, int l, int r) {
		if(b <= l || r <= a) return;
		if(a <= l && r <= b) {
			MUL(sum[k], s);
			MUL(lazy[k], s);
			MUL(mul[k], s);
			ADD(sum[k], (vx[r] - vx[l]) * s); //here too
			ADD(lazy[k], s);
		}
		else {
			lazy_eval(k, l, r);
			app(a, b, s, k * 2 + 1, l, (l + r) / 2);
			app(a, b, s, k * 2 + 2, (l + r) / 2, r);
			sum[k] = (sum[k * 2 + 1] + sum[k * 2 + 2]) % mod;
		}
	}
	ll ga(int a, int b, int k, int l, int r) {
		if(b <= l || r <= a) return ll();
		if(a <= l && r <= b) return sum[k];
		else {
			lazy_eval(k, l, r);
			ll lv = ga(a, b, k * 2 + 1, l, (l + r) / 2);
			ll rv = ga(a, b, k * 2 + 2, (l + r) / 2, r);
			return (lv + rv) % mod;
		}
	}
	void show() {
		vector<ll> tmp;
		rep(i, 0, n) tmp.push_back(get(i, i + 1));
		debug(tmp);
	}
	ll get(int a, int b) { return ga(a, b, 0, 0, n); } //[a, b)
	void update(int a, int b, ll s) { app(a, b, s, 0, 0, n); } //[a, b)
};


int fd(ll a) {
	return lower_bound(all(vx), a) - vx.begin();
}

ll N, Q;
ll X[MAX_N], L[MAX_N], R[MAX_N];
ll ans[MAX_N];

segtree seg[5];

void solve() {
	cin >> N >> Q;
	rep(i, 0, Q) {
		cin >> X[i] >> L[i] >> R[i]; R[i]++;
		vx.pb(L[i]); vx.pb(R[i]);
	}
	sort(all(vx)); vx.erase(unique(all(vx)), vx.end());
	rep(i, 0, 5) seg[i].init(sz(vx));
	// debug(vx);
	rep(i, 0, Q) {
		// rep(j, 0, 2) {
		// 	debug(i, j);
		// 	seg[j].show();
		// 	// debug(seg[j].zero);
		// 	// debug(seg[j].sum);
		// 	// debug(seg[j].lazy);
		// }
		int l = fd(L[i]), r = fd(R[i]);
		// debug(l, r, L[i], R[i]);
		if(X[i] == 0) {
			vector<ll> vec(5);
			rep(j, 0, 5) vec[j] = seg[j].get(l, r);
			int at = -1; ll mv = -linf;
			rep(j, 0, 5) {
				if(mv < vec[j]) {
					at = j; mv = vec[j];
				}
				else if(mv == vec[j]) at = -1;
			}
			if(at != -1) ADD(ans[at], vec[at]);
		}
		else {
			rep(j, 0, 5) {
				if(j == X[i] - 1) seg[j].update(l, r, 1);
				else seg[j].update(l, r, 0);
			}
		}
	}
	rep(j, 0, 5) {
		ADD(ans[j], seg[j].get(0, sz(vx)));
		cout << ans[j] << (j == 4 ? '\n' : ' ');
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

0