Submission #72686557


Source Code Expand

#include <stdio.h>
int n, q, a[200005];
long long pre[200005];
int main()
{
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", a + i);
		pre[i] = pre[i - 1] + a[i];
	}
	while (~--q)
	{
		int opt;
		scanf("%d", &opt);
		if (opt == 1)
		{
			int x;
			scanf("%d", &x);
			(pre[x] -= a[x]) += a[x + 1];
			a[x] ^= a[x + 1] ^= a[x] ^= a[x + 1];
		}
		else
		{
			int l, r;
			scanf("%d%d", &l, &r);
			printf("%lld\n", pre[r] - pre[l - 1]);
		}
	}
	return 0;
}

Submission Info

Submission Time
Task D - Swap and Range Sum
User XiangXunyi
Language C++23 (GCC 15.2.0)
Score 400
Code Size 506 Byte
Status AC
Exec Time 107 ms
Memory 8112 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1676 KiB
00_sample_01.txt AC 1 ms 1652 KiB
01_random_00.txt AC 107 ms 7316 KiB
01_random_01.txt AC 107 ms 6944 KiB
01_random_02.txt AC 102 ms 6272 KiB
01_random_03.txt AC 93 ms 5768 KiB
01_random_04.txt AC 93 ms 5396 KiB
01_random_05.txt AC 88 ms 4804 KiB
01_random_06.txt AC 82 ms 4388 KiB
01_random_07.txt AC 83 ms 3888 KiB
01_random_08.txt AC 75 ms 3844 KiB
01_random_09.txt AC 68 ms 3900 KiB
01_random_10.txt AC 59 ms 3788 KiB
01_random_11.txt AC 107 ms 8036 KiB
01_random_12.txt AC 106 ms 7528 KiB
01_random_13.txt AC 101 ms 6984 KiB
01_random_14.txt AC 97 ms 6136 KiB
01_random_15.txt AC 93 ms 5708 KiB
01_random_16.txt AC 89 ms 5352 KiB
01_random_17.txt AC 84 ms 4792 KiB
01_random_18.txt AC 80 ms 4264 KiB
01_random_19.txt AC 75 ms 4032 KiB
01_random_20.txt AC 69 ms 4048 KiB
01_random_21.txt AC 64 ms 3936 KiB
01_random_22.txt AC 85 ms 5512 KiB
01_random_23.txt AC 86 ms 5556 KiB
02_handmade_00.txt AC 1 ms 1608 KiB
02_handmade_01.txt AC 1 ms 1668 KiB
02_handmade_02.txt AC 100 ms 8112 KiB