QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#448634#6857. Easy problem IIRomeoAC ✓1815ms7588kbC++172.6kb2024-06-19 20:17:322024-06-19 20:17:32

Judging History

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

  • [2024-06-19 20:17:32]
  • 评测
  • 测评结果:AC
  • 用时:1815ms
  • 内存:7588kb
  • [2024-06-19 20:17:32]
  • 提交

answer

#include <iostream>
typedef long long ll;
namespace fraw
{
	#if !defined(LOCAL)
	const int N = 1e7;
	char buf[N], *p1 = buf, *p2 = buf;
	inline char gc() {return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, N, stdin), p1 == p2) ? EOF : *p1 ++ ;}
	char obuf[N], *p3 = obuf;
	inline void pc(char x) {(p3 - obuf < N) ? (*p3 ++ = x) : (fwrite(obuf, N, 1, stdout), p3 = obuf, *p3 ++ = x);}
	__attribute__((destructor)) inline void clear_obuf() {fwrite(obuf, p3 - obuf, 1, stdout);}
	#else
	inline char gc() {return getchar();}
	inline void pc(char x) {putchar(x);}
	#endif
	inline bool is_num(char ch) {return '0' <= ch && ch <= '9';}
	inline bool is_char(char ch) {return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z';}
	inline ll read()
	{
		char ch;
		ll f = 1, x = 0;
		while (!is_num(ch = gc())) if (ch == '-') f = -1;
		do x = (x << 1) + (x << 3) + ch - '0'; while (is_num(ch = gc()));
		return f * x;
	}
	void write(ll x)
	{
	    if (x < 0) {pc('-'); x = -x;}
	    if (x > 9) write(x / 10);
	    pc(x % 10 + '0');
	    return ;
	}
	inline void print(char s[]) {int i = 0; while (s[i]) pc(s[i ++ ]);}
	inline void put(char s[]) {print(s), pc('\n');}
} using fraw :: is_char, fraw :: is_num, fraw :: print, fraw :: write, fraw :: read, fraw :: put, fraw :: gc, fraw :: pc;
const ll N = 1e5;
ll a[N + 5];
int main()
{
	read();
	ll n = read(), m = read();
	for (ll i = 1; i <= n; i ++ ) a[i] = read();
	while (m -- )
	{
		ll type = read();
		if (type == 1)
		{
			ll l = read(), r = read(), x = read();
			ll i;
			for (i = l; i + 7 <= r; i += 8)
			{
				a[i] < x && (a[i] = x - a[i]) || (a[i] += x);
				a[i + 1] < x && (a[i + 1] = x - a[i + 1]) || (a[i + 1] += x);
				a[i + 2] < x && (a[i + 2] = x - a[i + 2]) || (a[i + 2] += x);
				a[i + 3] < x && (a[i + 3] = x - a[i + 3]) || (a[i + 3] += x);
				a[i + 4] < x && (a[i + 4] = x - a[i + 4]) || (a[i + 4] += x);
				a[i + 5] < x && (a[i + 5] = x - a[i + 5]) || (a[i + 5] += x);
				a[i + 6] < x && (a[i + 6] = x - a[i + 6]) || (a[i + 6] += x);
				a[i + 7] < x && (a[i + 7] = x - a[i + 7]) || (a[i + 7] += x);
			}
			for ( ; i <= r; i ++ ) a[i] < x && (a[i] = x - a[i]) || (a[i] += x);
		}
		if (type == 2)
		{
			ll l = read(), r = read();
			ll s, s0, s1, s2, s3, s4, s5, s6, s7;
			s = s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = 0;
			ll i;
			for (i = l; i + 7 <= r; i += 8) s0 += a[i], s1 += a[i + 1], s2 += a[i + 2], s3 += a[i + 3], s4 += a[i + 4], s5 += a[i + 5], s6 += a[i + 6], s7 += a[i + 7];
			for ( ; i <= r; i ++ ) s += a[i];
			s += s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7;
			write(s), pc('\n');
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1815ms
memory: 7588kb

input:

1
100000 100000
9994250 1 9999152 1 9996205 1 9993920 1 9992936 1 9999312 1 9994863 1 9999950 1 9994702 1 9998302 1 9997460 1 9995584 1 9990858 1 9995764 1 9992400 1 9992970 1 9993486 1 9992200 1 9991250 1 9990336 1 9994212 1 9992704 1 9999400 1 9994826 1 9996272 1 9995920 1 9994960 1 9996400 1 9990...

output:

474104664177
469903014249
480933011291
483822399944
484396591822
485195157450
476873328231
500050522935
490495899612
455001143708
459350186600
463088605817
452789422852
457530804729
478921256445
483860248443
460953094343
461203887676
471567676461
499102979676
483610787357
490750641096
468023668995
4...

result:

ok 85563 lines