输入样例2
2
6 6
200100
200211
5 3 1
2 0 1
2 0 3
2 0 2
2 3 3
0 1 3
输出样例2
3349208141
输入样例3
3
4
(???
输出样例3
2
输入样例4
3
4
)???
输出样例4
0
数据范围:| 任务编号 | 分值 | 测试点编号 | 数据范围与约定 |
| :-------------: | :-------------: | :-------------: | :-------------: |
| 1 | 5 | 1 | $n = 100000$ |
| 1 | 19 | 2 | $n = 10 ^ 8$ |
| 1 | 11 | 3 | $n = 2 \times 10 ^ 8$ |
| 2 | 7 | 4 | $n = q = 1000$ |
| 2 | 23 | 5 | $n = q = 300000$ |
| 3 | 9 | 6 | $n = 1000$ |
| 3 | 5 | 7 | $n = 120000$ |
| 3 | 7 | 8 | $n = 225000$ |
| 3 | 14 | 9 | $n = 266666$ |
### 模板程序
#### C++ 模板
``` cpp
#include
#include
#includetypedef unsigned int u32;
typedef unsigned long long u64;
inline u32 next_integer(u32 x) {
x ^= x << 13; x ^= x >> 17;
x ^= x << 5; return x; } bool output_arr(void *a, u32 size) { if (size % 4) { return puts("-1"), 0; } u32 blocks = size / 4; u32 *A = (u32 *)a; u32 ret = size; u32 x = 23333333; for (u32 i = 0; i < blocks; i++) { ret = ret ^ (A[i] + x); x ^= x << 13; x ^= x >> 17;
x ^= x << 5; } return printf("%u\n", ret), 1; } // ===== header ====== namespace Sorting { void init_data(u32 *a, int n, u32 seed) { for (int i = 0; i < n; i++) { seed = next_integer(seed); a[i] = seed; } } void main() { int n; u32 seed; scanf("%d%u", &n, &seed); u32 *a = new u32[n]; init_data(a, n, seed); // sort(a, n); output_arr(a, n * sizeof(u32)); } } namespace Game { void main() { int n, q; scanf("%d%d", &n, &q); char *s1 = new char[n + 1]; char *s2 = new char[n + 1]; scanf("%s%s", s1, s2); u32 *anss = new u32[q]; int *q_x = new int[q]; int *q_y = new int[q]; int *q_len = new int[q]; for (int i = 0; i < q; i++) { scanf("%d%d%d", q_x + i, q_y + i, q_len + i); } // solve(n, q, s1, s2, q_x, q_y, q_len, anss); output_arr(anss, q * sizeof(u32)); } } namespace Parentheses { void main() { int n; scanf("%d", &n); char *s = new char[n + 1]; scanf("%s", s); u32 ans; // ans = solve(n, s); printf("%u\n", ans); } } int main() { int task_id; scanf("%d", &task_id); switch (task_id) { case 1: Sorting::main(); break; case 2: Game::main(); break; case 3: Parentheses::main(); break; } return 0; } ``` #### C 模板 ``` c #include
#include
#include
#define bool int
#define true 1
#define false 0
typedef unsigned int u32;
typedef unsigned long long u64;
inline u32 next_integer(u32 x) {
x ^= x << 13; x ^= x >> 17;
x ^= x << 5; return x; } bool output_arr(void *a, u32 size) { if (size % 4) { return puts("-1"), 0; } u32 blocks = size / 4; u32 *A = (u32 *)a; u32 ret = size; u32 x = 23333333; u32 i; for (i = 0; i < blocks; i++) { ret = ret ^ (A[i] + x); x ^= x << 13; x ^= x >> 17;
x ^= x << 5; } return printf("%u\n", ret), 1; } // ===== header ====== void Sorting_main() { int n; u32 seed; scanf("%d%u", &n, &seed); u32 *a = malloc(n * sizeof(u32)); int i; for (i = 0; i < n; i++) { seed = next_integer(seed); a[i] = seed; } // sort(a, n); output_arr(a, n * sizeof(u32)); } void Game_main() { int n, q; scanf("%d%d", &n, &q); char *s1 = malloc((n + 1) * sizeof(char)); char *s2 = malloc((n + 1) * sizeof(char)); scanf("%s%s", s1, s2); u32 *anss = malloc(q * sizeof(u32)); int *q_x = malloc(q * sizeof(int)); int *q_y = malloc(q * sizeof(int)); int *q_len = malloc(q * sizeof(int)); int i; for (i = 0; i < q; i++) { scanf("%d%d%d", q_x + i, q_y + i, q_len + i); } // solve(n, q, s1, s2, q_x, q_y, q_len, anss); output_arr(anss, q * sizeof(u32)); } void Parentheses_main() { int n; scanf("%d", &n); char *s = malloc((n + 1) * sizeof(char)); scanf("%s", s); u32 ans; // ans = solve(n, s); printf("%u\n", ans); } int main() { int task_id; scanf("%d", &task_id); switch (task_id) { case 1: Sorting_main(); break; case 2: Game_main(); break; case 3: Parentheses_main(); break; } return 0; } ``` #### Pascal 模板 ``` pascal type u32 = dword; u64 = qword; u32_p = ^u32; u64_p = ^u64; longint_p = ^longint; function next_integer(x : u32) : u32; inline; begin x := x xor (x << 13); x := x xor (x >> 17);
x := x xor (x << 5); exit(x); end; function output_arr(a_in : pointer; size : u32) : boolean; var blocks : u32; a, a_ed : u32_p; ret, x : u32; begin if size mod 4 <> 0 then begin
writeln(-1);
exit(false);
end;
blocks := size div 4;
ret := size;
a := a_in;
a_ed := a + blocks;
x := 23333333;
while a < a_ed do begin ret := ret xor (a[0] + x); x := x xor (x << 13); x := x xor (x >> 17);
x := x xor (x << 5); inc(a); end; writeln(ret); exit(true); end; // ====== header ====== procedure init_data(a : u32_p; n : longint; seed : u32); var a_ed : u32_p; begin a_ed := a + n; while a < a_ed do begin seed := next_integer(seed); a[0] := seed; inc(a); end; end; procedure Sorting_main(); var n : longint; seed : u32; a : u32_p; i : u32; begin read(n, seed); a := Getmem(n * sizeof(u32)); init_data(a, n, seed); // sort(a, n); output_arr(a, n * sizeof(u32)); end; procedure Game_main(); var n, q : longint; s1, s2 : ansistring; anss : u32_p; q_x, q_y, q_len : longint_p; i : longint; begin readln(n, q); readln(s1); readln(s2); anss := Getmem(q * sizeof(u32)); q_x := Getmem(q * sizeof(longint)); q_y := Getmem(q * sizeof(longint)); q_len := Getmem(q * sizeof(longint)); for i := 0 to q - 1 do begin read(q_x[i], q_y[i], q_len[i]); end; // solve(n, q, s1, s2, q_x, q_y, q_len, anss); output_arr(anss, q * sizeof(u32)); end; procedure Parentheses_main(); var n : longint; s : ansistring; ans : u32; begin read(n); read(s); // ans := solve(n, s); writeln(ans); end; var task_id : longint; begin read(task_id); if task_id = 1 then begin Sorting_main(); end else if task_id = 2 then begin Game_main(); end else if task_id = 3 then begin Parentheses_main(); end; close(input); close(output); end. ```