#P11244. 吻秋
吻秋
Background
English statement. You must submit your code at the Chinese version of the statement.
After the autumn rain has just kissed the earth, white clouds roll up red, orange, yellow, green, cyan, blue, and purple.
Wavelengths within the visible light range fall freely, giving the rising water vapor a gradually changing rhythm.
The blurry impression of gradients is always hurried past by sunny days, but the often unusual range makes us remember it more clearly.
So, is being ordered really optimal?
Problem Description
Xiao C has integer sequences , and each sequence has length .
Xiao C wants to sort his sequences by integer value. So Xiao C has operations. In each operation:
- Either, Xiao C gives . He wants to concatenate and into a sequence of length . After sorting in nondecreasing order, take as the new , and take as the new .
- Or, Xiao C gives . Careful Xiao C wants to ask you: after the previous operations, what is the value of ? You need to answer his question exactly.
Input Format
The first line contains three integers .
The next lines each contain integers. The -th integer on the -th line denotes .
The next lines each contain three integers, describing one operation or one query, in one of the following two formats:
- means sorting and , where .
- means querying , where and .
Output Format
For each query, output one integer per line, representing the answer.
5 3 6
1 3 2 5 6
2 7 8 2 2
3 5 3 4 8
2 1 5
1 1 2
2 2 4
1 1 3
1 2 1
2 2 3
6
7
2
6 5 20
5 14 13 1 15 17
7 7 19 3 8 6
16 13 13 6 14 2
12 5 4 17 12 3
19 19 4 6 3 3
2 5 3
1 4 3
2 1 1
1 2 5
2 4 6
2 2 2
1 4 2
1 2 4
2 1 1
2 3 3
2 3 3
1 4 2
1 4 1
2 3 5
1 3 4
1 4 1
1 1 4
1 5 1
2 2 4
2 4 2
4
5
12
3
5
13
13
16
6
14
Hint
Constraints
This problem uses bundled test and subtask dependencies.
Because the maximum input sizes of the last two subtasks reach and more than respectively, C++ users may choose to use the following fast I/O template:
namespace FastIO {
char buf[1 << 21], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p1 = buf, p2 = (p1 + fread(buf, 1, 1 << 21, stdin))) == p1 ? EOF : *p1++)
template <typename T> inline T read() { T x = 0, w = 0; char ch = getchar(); while (ch < '0' || ch > '9') w |= (ch == '-'), ch = getchar(); while ('0' <= ch && ch <= '9') x = x * 10 + (ch ^ '0'), ch = getchar(); return w ? -x : x; }
template <typename T> inline void write(T x) { if (!x) return; write<T>(x / 10), putchar((x % 10) ^ '0'); }
template <typename T> inline void print(T x) { if (x > 0) write<T>(x); else if (x < 0) putchar('-'), write<T>(-x); else putchar('0'); }
template <typename T> inline void print(T x, char en) { print<T>(x), putchar(en); }
}; using namespace FastIO;
#undef getchar()
It is not guaranteed that languages other than C++ can pass, but sufficient time limits are guaranteed for C++.
- Subtask 0 (0 pts): samples.
- Subtask 1 (9 pts): , . Depends on Subtask .
- Subtask 2 (23 pts): . Depends on Subtasks .
- Subtask 3 (20 pts): , . Depends on Subtask .
- Subtask 4 (28 pts): . Depends on Subtasks .
- Subtask 5 (20 pts): no special constraints. Depends on Subtasks .
For all testdata, , , , and . For each operation or query, , , and .
Translated by ChatGPT 5