QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775884#9791. Intrusive Donkeyucup-team3282#WA 1ms7888kbC++141.5kb2024-11-23 16:58:032024-11-23 16:58:04

Judging History

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

  • [2024-11-23 16:58:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7888kb
  • [2024-11-23 16:58:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 200005;
int n, q;
char str[N];

ll sum[N * 4], lz[N * 4];
void up(int now)
{
	sum[now] = sum[now << 1] + sum[now << 1 | 1];
}
void upd(int now, ll v)
{
	sum[now] *= v;
	lz[now] *= v;
}
void down(int now)
{
	if (lz[now] != 1)
	{
		upd(now << 1, lz[now]);
		upd(now << 1 | 1, lz[now]);
		lz[now] = 1;
	}
}
void build(int now, int l, int r)
{
	lz[now] = 1;
	sum[now] = r - l + 1;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(now << 1, l, mid);
	build(now << 1 | 1, mid + 1, r);
}
void chg(int now, int l, int r, ll ql, ll qr)
{
	if (ql <= 1 && qr >= sum[now])
	{
		upd(now, 2);
		return;
	}
	if (l == r)
	{
		sum[now] += min(qr, sum[now]) - max(ql, 1ll) + 1;
		return;
	}
	int mid = (l + r) >> 1;
	down(now);
	chg(now << 1 | 1, mid + 1, r, ql - sum[now << 1], qr - sum[now << 1]);
	chg(now << 1, l, mid, ql, qr);
	up(now);
}
int query(int now, int l, int r, ll p)
{
	if (l == r) return l;
	int mid = (l + r) >> 1;
	down(now);
	if (p <= sum[now << 1]) return query(now << 1, l, mid, p);
	else return query(now << 1 | 1, mid + 1, r, p - sum[now << 1]);
}

int main()
{
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++)
		scanf(" %c", &str[i]);
	build(1, 1, n);
	int op;
	ll l, r;
	while (q--)
	{
		scanf("%d%lld", &op, &l);
		if (op == 1)
		{
			scanf("%lld", &r);
			chg(1, 1, n, l, r);
		}
		else
		{
			printf("%c\n", str[query(1, 1, n, l)]);
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7844kb

input:

4 7
abac
2 2
2 3
1 2 3
2 3
2 4
2 5
2 6

output:

b
a
b
a
a
c

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 5796kb

input:

5 4
shrek
1 1 2
2 7
1 1 7
2 7

output:

k
h

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 7888kb

input:

4 7
abac
2 2
2 3
1 2 3
2 3
2 4
2 5
2 6

output:

b
a
b
a
a
c

result:

ok 6 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 5856kb

input:

5 4
shrek
1 1 2
2 7
1 1 7
2 7

output:

k
h

result:

ok 2 lines

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 5840kb

input:

3 55
vfe
1 2 3
1 2 2
1 3 5
2 4
1 1 2
2 9
2 7
2 5
1 10 10
1 1 1
2 9
1 8 12
2 8
1 7 10
2 1
1 5 6
1 1 4
1 20 24
1 14 32
1 19 38
2 48
1 56 64
2 58
2 19
1 64 72
1 36 86
2 11
1 117 124
2 38
2 108
2 85
1 112 118
2 153
2 40
2 114
2 80
1 11 18
2 27
2 73
1 159 162
2 84
1 130 164
2 163
2 65
1 150 156
1 101 109...

output:

f
e
f
f
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e

result:

wrong answer 5th lines differ - expected: 'f', found: 'e'