QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#352393#7992. 【模板】线段树zzy0922Compile Error//C++145.0kb2024-03-13 10:47:232024-03-13 10:47:25

Judging History

你现在查看的是最新测评结果

  • [2024-03-13 10:47:25]
  • 评测
  • [2024-03-13 10:47:23]
  • 提交

answer

#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")


#include <bits/stdc++.h>

char buf[1 << 20], *p1, *p2;

#define gc() ((p1 == p2 && p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)

inline int read() {
	int res = 0;
	char c = gc();
	while (!isdigit(c)) c = gc();
	while (isdigit(c)) res = (res << 1) + (res << 3) + (c ^ 48), c = gc();
	return res;
} 

constexpr int N = 200005, mod = 1 << 20;

template<class T>
inline int fmod(T x) {
	return x & ((1 << 20) - 1);
}

int n, q;
int a[N];
int C[200005][25];

struct node {
	int l, r, v[22], t;
}tree[N << 2];

#define ls(p) (p << 1)
#define rs(p) (ls(p) | 1)
#define l(p)  tree[p].l
#define r(p)  tree[p].r
#define v(p)  tree[p].v
#define t(p)  tree[p].t
#define len(p) (r(p) - l(p) + 1)

inline void merge(int *c, int *a, int *b) {
	for (int i = 0; i < 20; i++) {
		c[i] = 0;
		for (int j = 0; j <= i; j++)
			c[i] = fmod(1ll * a[j] * b[i - j] + c[i]);
	}
}

inline void pushup(int p) {
	merge(v(p), v(ls(p)), v(rs(p)));
}

void build(int p, int l, int r) {
	// std::cout << p << ' ' << l << ' ' << r << '\n';
	l(p) = l, r(p) = r, t(p) = 0;
	if (l == r) {
		memset(v(p), 0, sizeof(v(p)));
		v(p)[0] = 1;
		v(p)[1] = a[l] - 1;
		return;
	}
	int mid = (l + r) >> 1;
	build(ls(p), l, mid);
	build(rs(p), mid + 1, r);
	pushup(p);
}

inline void node_add(int p, int x) {
	// std::cout << "ADD: " << p << ' ' << x << '\n';
	t(p) = fmod(t(p) + x);
	static int pow[22];
	pow[0] = 1;
	for (int i = 1; i < 20; i++) pow[i] = fmod(1ll * pow[i - 1] * x);
	for (int i = 19; i >= 0; i--) {
		for (int j = i - 1; j >= 0; j--) {
			v(p)[i] = fmod(1ll * fmod(1ll * v(p)[j] * pow[i - j]) * C[len(p) - j][i - j] + v(p)[i]);
		}
	}
}

inline void pushdown(int p) {
	if (!t(p)) return;
	// std::cout << "pushdown "<< p << ' ' << t(p) << '\n';
	node_add(ls(p), t(p));
	node_add(rs(p), t(p));
	t(p) = 0;
}

void add(int p, int l, int r, int x) {
	if (l > r(p) || r < l(p)) return;
	if (l <= l(p) && r(p) <= r) {
		node_add(p, x);
		return;
	}
	pushdown(p);
	add(ls(p), l, r, x);
	add(rs(p), l, r, x);
	pushup(p);
}

int ans[22];

void qry(int p, int l, int r) {
	if (l > r(p) || r < l(p)) return;
	if (l <= l(p) && r(p) <= r) {
		// std::cout << p << '\n';
		static int rans[22];
		memcpy(rans, ans, sizeof ans);
		merge(ans, rans, v(p));
		return;
	}
	pushdown(p);
	qry(ls(p), l, r);
	qry(rs(p), l, r);

}

inline int Qry(int l, int r) {
	memset(ans, 0, sizeof ans);
	ans[0] = 1;
	qry(1, l, r);
	int res = 0;
	for (int i = 0; i < 20; i++) res += ans[i];
	return fmod(res);
}

int main() {
	std::cin.tie(0)->sync_with_stdio(0);
	for (int i = 0; i <= 200000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= 20; j++) 
			C[i][j] = fmod(C[i - 1][j - 1] + C[i - 1][j]);
	}
	n = read(), q = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	build(1, 1, n);
	int op, l, r, x;
	while (q--) {
		op = read(), l = read(), r = read();
		if (op == 1) {
			x = read();
			add(1, l, r, x);
		} else {
			std::cout << Qry(l, r) << '\n';
	// for (int i = 0; i < 20; i++) std::cout << v(11)[i] << ' ';
		}
	}
}

详细

answer.code:22:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas]
   22 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
answer.code:29:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas]
   29 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
answer.code:31:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas]
   31 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
answer.code:45:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas]
   45 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
answer.code:56:17: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   56 | inline int read() {
      |                 ^
answer.code:56:17: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:56:17: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:56:17: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code: In function ‘int read()’:
answer.code:54:25: error: lvalue required as left operand of assignment
   54 | #define gc() ((p1 == p2 && p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)
      |                ~~~~~~~~~^~~~~
answer.code:58:18: note: in expansion of macro ‘gc’
   58 |         char c = gc();
      |                  ^~
answer.code:54:25: error: lvalue required as left operand of assignment
   54 | #define gc() ((p1 == p2 && p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)
      |                ~~~~~~~~~^~~~~
answer.code:59:33: note: in expansion of macro ‘gc’
   59 |         while (!isdigit(c)) c = gc();
      |                                 ^~
answer.code:54:25: error: lvalue required as left operand of assignment
   54 | #define gc() ((p1 == p2 && p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)
      |                ~~~~~~~~~^~~~~
answer.code:60:74: note: in expansion of macro ‘gc’
   60 |         while (isdigit(c)) res = (res << 1) + (res << 3) + (c ^ 48), c = gc();
      |                                                                          ^~
answer.code: At global scope:
answer.code:67:20: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   67 | inline int fmod(T x) {
      |                    ^
answer.code:67:20: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:67:20: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:67:20: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:41: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   87 | inline void merge(int *c, int *a, int *b) {
      |                                         ^
answer.code:87:41: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:41: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:87:41: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:95:25: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   95 | inline void pushup(int p) {
      |                         ^
answer.code:95:25: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:95:25: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:95:25: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:99:31: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   99 | void build(int p, int l, int r) {
      |                               ^
answer.code:99:31: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:99:31: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:99:31: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:114:34: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  114 | inline void node_add(int p, int x) {
      |                                  ^
answer.code:114:34: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:114:34: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:114:34: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:127:27: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  127 | inline void pushdown(int p) {
      |     ...