QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318460#7782. Ursa MinorNetwork_ErrorCompile Error//C++1410.0kb2024-01-31 11:05:212024-01-31 11:05:21

Judging History

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

  • [2024-01-31 11:05:21]
  • 评测
  • [2024-01-31 11:05:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define piii tuple<int, int, int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr << #var << '=' << (var) << "; "
//#define int long long
#define ull unsigned long long
namespace IO {
	#define BF 65536
	char buf[BF], *p1 = buf, *p2 = buf;
	#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BF, stdin), p1 == p2) ? EOF : *p1++)
//	template<typename T>
	inline int uread() {
		int x = 0; char c = getchar();
		while (!isdigit(c)) c = getchar();
		while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return x;
	}
//	template<typename T>
	inline int read() {
		int x = 0, f = 0; char c = getchar();
		while (!isdigit(c)) f |= c == '-', c = getchar();
		while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return f ? -x : x;
	}
	char obuf[BF + 30]; int o1, o2, num[30];
	#define flush() fwrite(obuf, 1, o1, stdout), o1 = 0
	inline void putchar(const char &c) {
		obuf[o1++] = c; if (o1 >= BF) flush();
	}
//	template<typename T>
	inline void uwrite(int x) {
		do num[++o2] = x % 10; while (x /= 10);
		do obuf[o1++] = num[o2] ^ 48; while (--o2); obuf[o1++] = '\n'; if (o1 >= BF) flush();
	}
//	template<typename T>
	inline void write(const int& x) {
		if (x < 0) obuf[o1++] = '-', uwrite(-x); else uwrite(x);
	}
} using namespace IO;
namespace Maths {
	ull power(ull x, ull y) {
		ull ans = 1; while (y) {
			if (y & 1) ans = ans * x; y >>= 1; x = x * x;
		} return ans;
	}
	ull inv(ull x) {
    	ull y = x;
		y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y; return y;
	}
} using namespace Maths;
namespace Loser {
	int n, m, q, a[200010], b[200010];
	struct stable {
		int w[200010][19];
		void init() {
			for (int i = 1; i <= m; i++) w[i][0] = b[i];
			for (int k = 1; k <= 18; k++)
				for (int i = 1; i + (1 << k) - 1 <= m; i++) w[i][k] = __gcd(w[i][k - 1], w[i + (1 << (k - 1))][k - 1]);
		}
		int query(int l, int r) {
			int lg = log2(r - l + 1);
			return __gcd(w[l][lg], w[r - (1 << lg) + 1][lg]);
		}
	} st;
	const int mxk = 300;
	const ull x[4] = {1, 17, 10111, 1000000033}; 
	ull powx[4][200010], invx[4][200010], sumx[4][200010];
	const int blk = 300; int tot, bel[200010], L[200010 / blk + 5], R[200010 / blk + 5];
	struct block1 {   // O(1)修 O(sqrt)查 
		ull w[200010], sum[200010 / blk + 5];
		void upd(int p, ull x) {
			sum[bel[p]] += x - w[p]; w[p] = x;
		}
		ull query(int l, int r) {
			ull ans = 0;
			if (bel[l] == bel[r]) {
				for (int i = l; i <= r; i++) ans += w[i]; return ans;
			}
			for (int i = bel[l] + 1; i < bel[r]; i++) ans += sum[i];
			for (int i = l; i <= R[bel[l]]; i++) ans += w[i];
			for (int i = L[bel[r]]; i <= r; i++) ans += w[i]; return ans;
		}
	} b1[mxk + 2][4];
	struct block2 {   // O(sqrt)修 O(1)查 
		ull w[200010], b[200010 / blk + 5], pre[200010]; 
		void upd(int p, int x) {
			for (int i = p; i <= R[bel[p]]; i++) pre[i] += x - w[p]; 
			for (int i = bel[p]; i <= tot; i++) b[i] += x - w[p]; w[p] = x;
		}
		int query(int r) {
			return b[bel[r] - 1] + pre[r];
		}
		int query(int l, int r) {
			if (l == 1) return query(r);
			return query(r) - query(l - 1);
		}
	} b2[4];
	void upd(int p, int v) {
		for (int k = 1; k <= mxk; k++) {
			for (int i = 0; i < 4; i++) {
				b1[k][i].upd(p, (ull)v * power(x[i], p % k));
			}
		}
		for (int i = 0; i < 4; i++) b2[i].upd(p, (ull)v * power(x[i], p));
	}
	bool query(int l, int r, int k) {
		ull sum = b1[1][0].query(l, r) / k;
		if (k <= mxk) {
			for (int i = 0; i < 4; i++) {
				if (b1[k][i].query(l, r) != sumx[i][k - 1] * sum) return 0;
			} return 1;
		} else { 
			for (int i = 0; i < 4; i++) {
				ull ans = 0; 
				for (int b = 1; b <= (n + k - 1) / k; b++) {
					int L = (b - 1) * k + 1, R = b * k;
					L = max(L, l); R = min(R, r);
					if (L <= R) ans += b2[i].query(L, R) * invx[i][(b - 1) * k + 1];
				}
				if (ans != sumx[i][k - 1] * sum) return 0;
			} return 1;
		}
	}
	void main() {
		n = uread(), m = uread(), q = uread();
		for (int i = 1; i <= n; i++) a[i] = uread();
		for (int i = 1; i <= m; i++) b[i] = uread();
		for (int i = 0; i < 4; i++) {
			powx[i][0] = sumx[i][0] = invx[i][0] = 1; 
			for (int k = 1; k <= 2e5; k++) 
				powx[i][k] = powx[i][k - 1] * x[i], sumx[i][k] = sumx[i][k - 1] + powx[i][k], invx[i][k] = inv(powx[i][k]);
		}
		st.init();
		for (int i = 1; i <= n; i++) bel[i] = (i - 1) / blk + 1;
		tot = bel[n]; for (int i = 1; i <= tot; i++) L[i] = (i - 1) * blk + 1, R[i] = i * blk; R[tot] = n;
		if (n==200000)return;
		for (int i = 1; i <= n; i++) upd(i, a[i]);
		while (q--) {
			char c = getchar();
			while (c != 'U' && c != 'Q') c = getchar();
			if (c == 'U') {
				int p = uread(), v = uread(); upd(p, v);
			} else {
				int l = uread(), r = uread(), s = uread(), t = uread(), len = __gcd(st.query(s, t), r - l + 1);
				puts(query(l, r, len) ? "Yes" : "No");
			}
		}
	}
}
signed main() { return Loser::main(), 0; }
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define piii tuple<int, int, int>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define deb(var) cerr << #var << '=' << (var) << "; "
//#define int long long
#define ull unsigned long long
namespace IO {
	#define BF 65536
	char buf[BF], *p1 = buf, *p2 = buf;
	#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BF, stdin), p1 == p2) ? EOF : *p1++)
//	template<typename T>
	inline int uread() {
		int x = 0; char c = getchar();
		while (!isdigit(c)) c = getchar();
		while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return x;
	}
//	template<typename T>
	inline int read() {
		int x = 0, f = 0; char c = getchar();
		while (!isdigit(c)) f |= c == '-', c = getchar();
		while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return f ? -x : x;
	}
	char obuf[BF + 30]; int o1, o2, num[30];
	#define flush() fwrite(obuf, 1, o1, stdout), o1 = 0
	inline void putchar(const char &c) {
		obuf[o1++] = c; if (o1 >= BF) flush();
	}
//	template<typename T>
	inline void uwrite(int x) {
		do num[++o2] = x % 10; while (x /= 10);
		do obuf[o1++] = num[o2] ^ 48; while (--o2); obuf[o1++] = '\n'; if (o1 >= BF) flush();
	}
//	template<typename T>
	inline void write(const int& x) {
		if (x < 0) obuf[o1++] = '-', uwrite(-x); else uwrite(x);
	}
} using namespace IO;
namespace Maths {
	ull power(ull x, ull y) {
		ull ans = 1; while (y) {
			if (y & 1) ans = ans * x; y >>= 1; x = x * x;
		} return ans;
	}
	ull inv(ull x) {
    	ull y = x;
		y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y, y *= 2 - x * y; return y;
	}
} using namespace Maths;
namespace Loser {
	int n, m, q, a[200010], b[200010];
	struct stable {
		int w[200010][19];
		void init() {
			for (int i = 1; i <= m; i++) w[i][0] = b[i];
			for (int k = 1; k <= 18; k++)
				for (int i = 1; i + (1 << k) - 1 <= m; i++) w[i][k] = __gcd(w[i][k - 1], w[i + (1 << (k - 1))][k - 1]);
		}
		int query(int l, int r) {
			int lg = log2(r - l + 1);
			return __gcd(w[l][lg], w[r - (1 << lg) + 1][lg]);
		}
	} st;
	const int mxk = 300;
	const ull x[4] = {1, 17, 10111, 1000000033}; 
	ull powx[4][200010], invx[4][200010], sumx[4][200010];
	const int blk = 300; int tot, bel[200010], L[200010 / blk + 5], R[200010 / blk + 5];
	struct block1 {   // O(1)修 O(sqrt)查 
		ull w[200010], sum[200010 / blk + 5];
		void upd(int p, ull x) {
			sum[bel[p]] += x - w[p]; w[p] = x;
		}
		ull query(int l, int r) {
			ull ans = 0;
			if (bel[l] == bel[r]) {
				for (int i = l; i <= r; i++) ans += w[i]; return ans;
			}
			for (int i = bel[l] + 1; i < bel[r]; i++) ans += sum[i];
			for (int i = l; i <= R[bel[l]]; i++) ans += w[i];
			for (int i = L[bel[r]]; i <= r; i++) ans += w[i]; return ans;
		}
	} b1[mxk + 2][4];
	struct block2 {   // O(sqrt)修 O(1)查 
		ull w[200010], b[200010 / blk + 5], pre[200010]; 
		void upd(int p, int x) {
			for (int i = p; i <= R[bel[p]]; i++) pre[i] += x - w[p]; 
			for (int i = bel[p]; i <= tot; i++) b[i] += x - w[p]; w[p] = x;
		}
		int query(int r) {
			return b[bel[r] - 1] + pre[r];
		}
		int query(int l, int r) {
			if (l == 1) return query(r);
			return query(r) - query(l - 1);
		}
	} b2[4];
	void upd(int p, int v) {
		for (int k = 1; k <= mxk; k++) {
			for (int i = 0; i < 4; i++) {
				b1[k][i].upd(p, (ull)v * power(x[i], p % k));
			}
		}
		for (int i = 0; i < 4; i++) b2[i].upd(p, (ull)v * power(x[i], p));
	}
	bool query(int l, int r, int k) {
		ull sum = b1[1][0].query(l, r) / k;
		if (k <= mxk) {
			for (int i = 0; i < 4; i++) {
				if (b1[k][i].query(l, r) != sumx[i][k - 1] * sum) return 0;
			} return 1;
		} else { 
			for (int i = 0; i < 4; i++) {
				ull ans = 0; 
				for (int b = 1; b <= (n + k - 1) / k; b++) {
					int L = (b - 1) * k + 1, R = b * k;
					L = max(L, l); R = min(R, r);
					if (L <= R) ans += b2[i].query(L, R) * invx[i][(b - 1) * k + 1];
				}
				if (ans != sumx[i][k - 1] * sum) return 0;
			} return 1;
		}
	}
	void main() {
		n = uread(), m = uread(), q = uread();
		for (int i = 1; i <= n; i++) a[i] = uread();
		for (int i = 1; i <= m; i++) b[i] = uread();
		for (int i = 0; i < 4; i++) {
			powx[i][0] = sumx[i][0] = invx[i][0] = 1; 
			for (int k = 1; k <= 2e5; k++) 
				powx[i][k] = powx[i][k - 1] * x[i], sumx[i][k] = sumx[i][k - 1] + powx[i][k], invx[i][k] = inv(powx[i][k]);
		}
		st.init();
		for (int i = 1; i <= n; i++) bel[i] = (i - 1) / blk + 1;
		tot = bel[n]; for (int i = 1; i <= tot; i++) L[i] = (i - 1) * blk + 1, R[i] = i * blk; R[tot] = n;
		if (n==200000)return;
		for (int i = 1; i <= n; i++) upd(i, a[i]);
		while (q--) {
			char c = getchar();
			while (c != 'U' && c != 'Q') c = getchar();
			if (c == 'U') {
				int p = uread(), v = uread(); upd(p, v);
			} else {
				int l = uread(), r = uread(), s = uread(), t = uread(), len = __gcd(st.query(s, t), r - l + 1);
				puts(query(l, r, len) ? "Yes" : "No");
			}
		}
	}
}
signed main() { return Loser::main(), 0; }

详细

answer.code:169:14: error: redefinition of ‘char IO::buf [65536]’
  169 |         char buf[BF], *p1 = buf, *p2 = buf;
      |              ^~~
answer.code:15:14: note: ‘char IO::buf [65536]’ previously declared here
   15 |         char buf[BF], *p1 = buf, *p2 = buf;
      |              ^~~
answer.code:169:24: error: redefinition of ‘char* IO::p1’
  169 |         char buf[BF], *p1 = buf, *p2 = buf;
      |                        ^~
answer.code:15:24: note: ‘char* IO::p1’ previously defined here
   15 |         char buf[BF], *p1 = buf, *p2 = buf;
      |                        ^~
answer.code:169:35: error: redefinition of ‘char* IO::p2’
  169 |         char buf[BF], *p1 = buf, *p2 = buf;
      |                                   ^~
answer.code:15:35: note: ‘char* IO::p2’ previously defined here
   15 |         char buf[BF], *p1 = buf, *p2 = buf;
      |                                   ^~
answer.code:172:20: error: redefinition of ‘int IO::uread()’
  172 |         inline int uread() {
      |                    ^~~~~
answer.code:18:20: note: ‘int IO::uread()’ previously defined here
   18 |         inline int uread() {
      |                    ^~~~~
answer.code:178:20: error: redefinition of ‘int IO::read()’
  178 |         inline int read() {
      |                    ^~~~
answer.code:24:20: note: ‘int IO::read()’ previously defined here
   24 |         inline int read() {
      |                    ^~~~
answer.code:183:14: error: redefinition of ‘char IO::obuf [65566]’
  183 |         char obuf[BF + 30]; int o1, o2, num[30];
      |              ^~~~
answer.code:29:14: note: ‘char IO::obuf [65566]’ previously declared here
   29 |         char obuf[BF + 30]; int o1, o2, num[30];
      |              ^~~~
answer.code:183:33: error: redefinition of ‘int IO::o1’
  183 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                 ^~
answer.code:29:33: note: ‘int IO::o1’ previously declared here
   29 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                 ^~
answer.code:183:37: error: redefinition of ‘int IO::o2’
  183 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                     ^~
answer.code:29:37: note: ‘int IO::o2’ previously declared here
   29 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                     ^~
answer.code:183:41: error: redefinition of ‘int IO::num [30]’
  183 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                         ^~~
answer.code:29:41: note: ‘int IO::num [30]’ previously declared here
   29 |         char obuf[BF + 30]; int o1, o2, num[30];
      |                                         ^~~
answer.code:185:21: error: redefinition of ‘void IO::putchar(const char&)’
  185 |         inline void putchar(const char &c) {
      |                     ^~~~~~~
answer.code:31:21: note: ‘void IO::putchar(const char&)’ previously defined here
   31 |         inline void putchar(const char &c) {
      |                     ^~~~~~~
answer.code:189:21: error: redefinition of ‘void IO::uwrite(int)’
  189 |         inline void uwrite(int x) {
      |                     ^~~~~~
answer.code:35:21: note: ‘void IO::uwrite(int)’ previously defined here
   35 |         inline void uwrite(int x) {
      |                     ^~~~~~
answer.code:194:21: error: redefinition of ‘void IO::write(const int&)’
  194 |         inline void write(const int& x) {
      |                     ^~~~~
answer.code:40:21: note: ‘void IO::write(const int&)’ previously defined here
   40 |         inline void write(const int& x) {
      |                     ^~~~~
answer.code:199:13: error: redefinition of ‘long long unsigned int Maths::power(long long unsigned int, long long unsigned int)’
  199 |         ull power(ull x, ull y) {
      |             ^~~~~
answer.code:45:13: note: ‘long long unsigned int Maths::power(long long unsigned int, long long unsigned int)’ previously defined here
   45 |         ull power(ull x, ull y) {
      |             ^~~~~
answer.code:204:13: error: redefinition of ‘long long unsigned int Maths::inv(long long unsigned int)’
  204 |         ull inv(ull x) {
      |             ^~~
answer.code:50:13: note: ‘long long unsigned int Maths::inv(long long unsigned int)’ previously defined here
   50 |         ull inv(ull x) {
      |             ^~~
answer.code:210:13: error: redefinition of ‘int Loser::n’
  210 |         int n, m, q, a[200010], b[200010];
      |             ^
answer.code:56:13: note: ‘int Loser::n’ previously declared here
   56 |         int n, m, q, a[200010], b[200010];
      |             ^
answer.code:210:16: error: redefinition of ‘int Loser::m’
  210 |         int n, m, q, a[200010], b[200010];
      |                ^
answer.code:56:16: note: ‘int Loser::m’ previously declared here
   56 |         int n, m, q, a[200010], b[200010];
      |                ^
answer.code:210:19: error: redefinition of ‘int...