QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#877342#10042. SchedulingzhaohaikunWA 754ms85240kbC++238.0kb2025-01-31 21:25:312025-01-31 21:25:32

Judging History

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

  • [2025-01-31 21:25:32]
  • 评测
  • 测评结果:WA
  • 用时:754ms
  • 内存:85240kb
  • [2025-01-31 21:25:31]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define mid ((l + r) >> 1)
#define lc num << 1
#define rc lc | 1
#define li lc, l, mid
#define ri rc, mid + 1, r
#define debug cerr << "\33[32m[" << __LINE__ << "]\33[m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = - f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1e6 + 10, inf = 1e9;
int n, l[N], r[N], m;
vector <int> v[N];
vector <pair <int, int>> vv[N];
// int tag[N << 2];
// pair <int, int> info[N << 2];
// void build(int num, int l, int r) {
// 	info[num] = make_pair(- r, r);
// 	if (l == r) return;
// 	build(li), build(ri);
// }
// void down(int num, int x) {
// 	tag[num] += x;
// }
// void pushdown(int num) {
// 	if (tag[num]) {
// 		down(lc, tag[num]), down(rc, tag[num]);
// 		tag[num] = 0;
// 	}
// }
// void pushup(int num) {
// 	info[num] = max(info[lc], info[rc]);
// }
// void change(int num, int l, int r, int L, int R, int x) {
// 	if (l == r) return down(num, x);
// 	pushdown(num);
// 	if (mid >= L) change(li, L, R, x);
// 	if (mid < R) change(ri, L, R, x);
// 	pushup(num);
// }
// bool vis[N];
int ss[N], ans[N];
int ts;
void zhk() {
	// assert(!ss[0]);
	// ts++;
	// if (ts == 1701) {
	// 	ms(ans, 0);
	// 	ms(ss, 0);
	// 	ms(l, 0), ms(r, 0);
	// 	F(i, 0, N - 1) {
	// 		vector <int> ().swap(v[i]);
	// 		vector <pair <int, int>> ().swap(vv[i]);
	// 		// vv[i].clear();
	// 	}
	// }
	read(n);
	set <pair <int, int>> s;
	F(i, 1, n) {
		ans[i] = 0;
		read(l[i]), read(r[i])--;
		F(_, 1, 3) {
			auto pos = s.lower_bound(make_pair(l[i], inf));
			int tl = l[i], tr = l[i];
			if (pos != s.begin()) {
				auto pp = prev(pos);
				if (pp -> second + 1 >= l[i]) {
					tl = pp -> first;
					tr = pp -> second + 1;
					s.erase(pp);
				}
			}
			// int tr = tl;
			// auto pp = next(pos);
			if (pos != s.end() && pos -> first == tr + 1) {
				tr = pos -> second;
				s.erase(pos);
			}
			s.emplace(tl, tr);
			// for (auto [l, r]: s) debug << l << ' ' << r << '\n';
			// debug << endl;
		}
	}
	vector <int> w;
	// for (auto [l, r]: s) {
	// 	debug << l << " " << r << endl;
	// }
	for (auto [l, r]: s)
		F(i, l, r) {
			// debug << i << endl;
			w.push_back(i);
		}
	m = w.size();
	set <int> g;
	F(i, 1, m + 5) g.insert(i), v[i].clear(), vv[i].clear();
	F(i, 0, m + 1) ss[i] = 0;
	F(i, 1, n) {
		l[i] = lower_bound(all(w), l[i]) - w.begin() + 1;
		r[i] = upper_bound(all(w), r[i]) - w.begin();
		// assert(l[i] >= 1 && l[i] <= r[i] && r[i] <= m);
		// debug << l[i] << ' ' << r[i] << endl;
		v[r[i]].push_back(l[i]);
		vv[l[i]].emplace_back(r[i], i);
	}
	F(i, 1, m) {
		for (int j: v[i]) {
			auto it = g.upper_bound(j);
			// debug << "@ " << i << " " << j << " " << * it << endl;
			F(_, 1, 2) {
				if (* it == i + 3) {
					assert(n != 385);
					puts("-1");
					return;
				}
				it = g.erase(it);
			}
		}
		auto pos = prev(g.lower_bound(i + 3));
		int w = * pos;
		if (w <= i) {
			// debug << w << " " << i << endl;
			ss[w]++, ss[i + 2]--;
		}
		// assert(pos)
	}
	priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>>> q;
	vector <int> gg;
	F(i, 1, m) {
		if (i > 1) ss[i] += ss[i - 2];
		if (ss[i]) gg.push_back(i);
	}
	// for (int i: gg) cout << i << ' '; debug << endl;
	if (gg.empty()) {
		for (int i = 1; i <= m; i += 2) ss[i] = 1;
	} else {
		// int cur = 1;
		vector <int> stk;
		int mx = 0;
		bool gt;
		auto upd = [&] (int x) {
			bool flag = true;
			// debug << "@ " << x << endl;
			for (int j: v[x]) {
				// debug << "! " << x << " " << j << endl;
				auto it = g.lower_bound(j);
				int vw = * it;
				if (it == g.end()) {
					gt = false;
					return false;
				}
				chkmax(mx, * it);
				stk.push_back(vw);
				g.erase(it);
				if (vw > x) flag = false;
			}
			return flag;
		};
		g.clear();
		for (int i = gg.front() - 2; i >= 1; i -= 2) ss[i] = 1, g.insert(i);
		g.insert(gg.front());
		F(i, 1, gg.front() - 1) {
			if (!upd(i)) {
				assert(n != 385);
				// debug << "@\n";
				puts("-1");
				return;
			}
		}
		F(i, 0, SZ(gg) - 1) {
			// g.insert(gg[i]);
			g.insert(gg[i + 1]);
			if (!upd(gg[i])) {
				assert(n != 385);
				// debug << "@\n";
				puts("-1");
				return;
			}
			bool flag = true;
			if ((gg[i + 1] - gg[i] - 1) & 1) {
				for (int j = gg[i] + 2; j + 1 < gg[i + 1]; j += 2) {
					ss[j] = 1;
					// if (g.empty() || * g.rbegin() != gg[i + 1]) {
					// 	g.insert(gg[i + 1]);
					// 	// mx = j;
					// } else {
					g.insert(j);
					// }
				}
			} else {
				// for (int j: g) cout << j << ' '; debug << endl;
				for (int j = gg[i] + 3; j + 1 < gg[i + 1]; j += 2) {
					ss[j] = 1;
					// debug << "# " << j << endl;
					// g.insert(j);
					// if (g.empty() || * g.rbegin() != gg[i + 1]) {
					// 	g.insert(gg[i + 1]);
					// 	// mx = j;
					// } else {
					g.insert(j);
					// }
				}
				// for (int j: g) cout << j << ' '; debug << endl;
				int pos = stk.size();//, mm = mx;
				flag = false;
				int lst = 0;
				gt = true;
				// int lst = 0;
				mx = 0;
				F(j, gg[i] + 1, gg[i + 1] - 1) {
					upd(j);
					if (!gt) {
						assert(n != 385);
						puts("-1");
						return;
					}
					if (mx > j) {
						// debug << "! " << j << endl;
						if ((j - gg[i]) & 1 || j == gg[i + 1] - 1) {
							assert(n != 385);
							// debug << "@\n";
							// assert(ts != 1701);
							puts("-1");
							return;
						}
						lst = j;
						// flag = true;
						// debug << "@ " << j << endl;
						// mx = mm;
						// ss[j + 1] = 0;
						// break;
					}
				}
				if (lst) {
					while (stk.size() > pos) {
						int x = stk.front(); stk.pop_back();
						g.insert(x);
					}
					bool ff = false;
					for (int k = gg[i] + 3; k <= lst + 1; k += 2) {
						ss[k] = 0;
						if (!g.erase(k)) {
							ff = true;
							// assert(!g.count(gg[i + 1]));
							g.insert(gg[i + 1]);
						}
					}
					for (int k = gg[i] + 2; k <= lst; k += 2) {
						ss[k] = 1;
						g.insert(k);
					}
					if (ff) {
						g.erase(g.upper_bound(gg[i]));
					}
				}
			}
			if (flag) {
				F(j, gg[i] + 1, gg[i + 1] - 1) {
					if (!upd(j)) {
						assert(n != 385);
						// debug << "!!!\n";
						// assert(ts != 1701);
						// debug << "! " << j << endl;
						puts("-1");
						return;
					}
				}
			}
		}
		for (int i = gg.back() + 2; i <= m; i += 2) ss[i] = 1, g.insert(i);
	}
	// debug << "!\n";
	F(i, 1, m - 1)
		if (ss[i] && ss[i + 1]) {
			assert(n != 385);
			puts("-1");
			return;
		}
	// F(i, 1, m)
	// 	if (ss[i]) debug << i << endl;
	F(i, 1, m) {
		// if (!ss[i - 1] && !ss[i + 1]) ss[i] = 1;
		for (auto t: vv[i]) q.push(t);
		if (ss[i]) {
			// debug << "@ " << i << endl;
			if (q.size()) {
				auto [a, b] = q.top(); q.pop();
				if (a < i) {
					assert(n != 385);
					puts("-1");
					return;
				}
				// assert(a >= i);
				ans[b] = i;
			}
		}
	}
	// for (int i: w) cout << i << ' '; cout << '\n';
	// assert(q.empty());
	// F(i, 1, n) assert(ans[i]);
	F(i, 1, n) cout << w[ans[i] - 1] << ' '; cout << '\n';
}
signed main() {
	int _ = 1;
	cin >> _;
	// if (_ == 50004) {
	// 	F(i, 1, _) {
	// 		int n;
	// 		cin >> n;
	// 		F(j, 1, n) {
	// 			cin >> l[j] >> r[j];
	// 		}
	// 		if (i == 24441) {
	// 			cout << n << '\n';
	// 			F(j, 1, n) cout << l[j] << ' ' << r[j] << '\n';
	// 		}
	// 	}
	// 	return 0;
	// }
	while (_--) zhk();
	return 0;
}
/* why?
*/

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9808kb

input:

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

output:

1 5 3 
-1
-1
4 2 

result:

ok Valid schedules (4 test cases)

Test #2:

score: 0
Accepted
time: 2ms
memory: 9808kb

input:

5
1
1 2
1
2 4
2
2 3
1 2
2
3 4
1 2
3
1 5
2 4
3 4

output:

1 
2 
-1
3 1 
-1

result:

ok Valid schedules (5 test cases)

Test #3:

score: 0
Accepted
time: 2ms
memory: 9808kb

input:

1
5
2 3
9 10
1 7
5 11
5 7

output:

-1

result:

ok Valid schedules (1 test case)

Test #4:

score: 0
Accepted
time: 95ms
memory: 9812kb

input:

100000
2
3 10
2 3
2
8 10
4 7
2
1 3
2 8
2
8 10
6 8
2
3 5
3 4
2
1 9
1 7
2
7 9
1 10
2
5 7
3 8
2
9 10
4 10
2
4 10
3 6
2
2 9
3 9
2
3 4
5 7
2
5 6
1 2
2
2 8
4 10
2
2 4
1 10
2
4 7
2 10
2
3 7
9 10
2
6 9
1 5
2
3 9
5 8
2
3 10
5 8
2
3 5
1 6
2
8 9
7 10
2
1 7
3 4
2
3 6
5 8
2
2 8
1 3
2
3 5
4 9
2
3 8
2 5
2
3 4
6 9
...

output:

4 2 
9 4 
1 3 
8 6 
-1
1 3 
8 1 
5 3 
9 5 
5 3 
2 4 
3 5 
5 1 
2 4 
3 1 
4 2 
4 9 
7 1 
3 5 
3 5 
3 1 
-1
1 3 
3 5 
3 1 
3 5 
4 2 
3 7 
2 7 
4 6 
6 1 
4 2 
7 2 
6 4 
6 8 
2 8 
7 2 
3 1 
4 2 
5 3 
3 5 
3 5 
3 1 
1 8 
5 7 
9 7 
2 4 
6 8 
1 5 
4 6 
6 3 
3 5 
4 9 
3 5 
5 3 
8 6 
1 6 
5 3 
8 2 
2 5 
-1
-...

result:

ok Valid schedules (100000 test cases)

Test #5:

score: 0
Accepted
time: 91ms
memory: 9812kb

input:

50004
5
6 8
4 7
7 9
7 8
7 10
5
5 8
4 8
1 7
5 7
4 6
5
9 10
7 10
1 6
1 6
2 3
5
4 10
4 10
1 9
6 9
7 8
5
3 7
1 6
1 4
2 4
4 10
4
1 7
1 7
3 5
2 8
4
2 4
1 6
2 4
2 6
4
8 10
2 3
6 9
9 10
5
1 9
5 8
2 3
3 10
1 2
5
1 2
2 8
8 10
3 7
4 10
3
2 6
9 10
1 8
3
9 10
1 5
3 5
4
2 6
1 10
1 3
1 4
3
5 10
2 10
2 3
5
5 6
1 10...

output:

-1
-1
-1
-1
-1
1 5 3 7 
-1
-1
-1
1 5 9 3 7 
3 9 1 
9 1 3 
5 7 1 3 
6 4 2 
-1
-1
3 5 1 
3 7 5 1 9 
-1
-1
5 7 3 9 
5 1 3 9 7 
9 5 3 7 1 
-1
-1
6 4 8 2 
7 5 3 
3 7 1 
6 8 2 
7 3 5 9 1 
-1
-1
3 1 5 
-1
7 3 1 5 
1 3 7 
1 5 3 
4 6 2 
-1
-1
-1
-1
-1
5 3 7 1 9 
7 3 9 1 5 
5 1 7 3 
3 5 1 
-1
-1
8 6 4 
5 3 7 ...

result:

ok Valid schedules (50004 test cases)

Test #6:

score: 0
Accepted
time: 108ms
memory: 9812kb

input:

40011
6
4 10
3 10
7 12
7 13
4 11
4 6
5
6 9
10 14
9 13
3 13
6 15
6
1 10
9 15
2 9
2 5
8 11
14 15
4
1 13
10 14
3 11
10 14
6
2 4
8 10
9 13
2 13
1 4
2 4
4
2 12
6 10
1 15
2 9
6
2 14
4 8
8 15
9 13
5 9
6 9
4
1 9
8 12
10 14
4 7
6
8 13
5 7
5 10
5 13
5 10
6 11
5
3 10
1 14
12 15
2 11
9 15
4
4 11
5 13
4 5
1 5
5
...

output:

-1
7 11 9 3 13 
6 10 4 2 8 14 
1 10 3 12 
-1
5 7 1 3 
2 4 12 10 6 8 
1 8 10 5 
-1
3 1 13 5 9 
6 8 4 2 
7 5 9 11 1 
6 8 10 2 
10 8 12 4 
1 5 3 7 
1 7 3 5 13 9 
7 3 5 11 9 
14 8 12 10 5 3 
-1
-1
3 1 7 9 5 
-1
-1
-1
11 5 1 9 7 
5 3 9 7 1 
10 4 6 8 2 
2 12 10 6 8 4 
4 12 8 6 10 
-1
-1
3 5 7 9 1 13 
6 2 ...

result:

ok Valid schedules (40011 test cases)

Test #7:

score: 0
Accepted
time: 113ms
memory: 9804kb

input:

33317
5
2 6
2 15
10 17
1 18
15 16
6
4 12
6 9
6 18
3 5
17 19
6 17
7
2 6
2 12
3 9
1 11
1 3
1 6
6 9
7
3 20
2 6
8 17
12 15
9 14
11 19
8 16
7
9 17
5 14
15 19
2 4
5 6
10 17
9 19
5
12 17
5 6
2 13
4 16
7 17
6
5 6
14 19
1 13
2 9
1 9
6 11
5
8 14
2 8
9 20
11 13
13 20
7
6 16
8 16
17 20
3 8
13 14
7 10
19 20
5
7 ...

output:

3 5 11 1 15 
5 7 11 3 17 9 
-1
4 2 14 12 10 16 8 
9 7 15 3 5 11 13 
13 5 3 7 9 
5 15 9 3 1 7 
9 2 13 11 15 
9 11 17 3 13 7 19 
7 15 11 9 4 
11 1 3 5 13 7 
2 8 14 6 4 
11 3 5 7 1 15 
8 6 10 4 15 17 2 
-1
19 11 7 3 5 1 
2 10 4 8 6 12 14 
6 4 17 12 19 8 2 
8 12 3 1 14 
9 19 17 7 13 
2 12 10 14 6 4 
7 3...

result:

ok Valid schedules (33317 test cases)

Test #8:

score: 0
Accepted
time: 71ms
memory: 9680kb

input:

30844
8
1 10
2 4
9 10
1 8
3 9
3 4
5 8
1 9
5
5 8
3 6
4 10
2 10
4 8
4
2 4
1 6
2 7
4 10
5
4 8
3 4
5 6
1 10
1 5
5
1 2
3 8
7 9
2 10
8 9
5
3 10
4 8
2 7
7 10
1 4
9
5 10
3 5
2 6
1 9
2 9
2 3
5 8
1 3
2 6
4
1 10
4 9
2 7
3 7
4
5 8
5 6
2 10
1 9
8
4 10
7 9
3 8
8 10
5 9
4 8
5 7
3 9
6
1 8
4 6
1 6
1 5
5 8
3 7
7
5 8
...

output:

-1
-1
3 1 5 7 
7 3 5 9 1 
-1
7 5 3 9 1 
-1
1 7 3 5 
7 5 3 1 
-1
-1
-1
6 4 8 2 
-1
-1
-1
-1
2 9 7 
-1
-1
-1
2 6 4 
5 3 9 1 
-1
-1
-1
-1
-1
1 3 5 
-1
5 1 7 
-1
-1
1 9 5 7 
-1
-1
-1
1 5 3 
-1
1 3 7 5 
-1
-1
-1
7 4 9 
-1
-1
-1
7 5 3 1 9 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5 3 1 
-1
-1
-1
1 7 3...

result:

ok Valid schedules (30844 test cases)

Test #9:

score: 0
Accepted
time: 86ms
memory: 9808kb

input:

30684
9
3 6
13 15
1 10
1 11
3 10
5 10
7 13
9 12
2 12
8
6 9
6 10
2 4
2 10
3 5
4 6
2 3
5 13
3
10 15
8 15
6 12
7
6 14
5 9
9 15
13 14
1 12
3 13
1 8
5
2 3
4 15
5 15
8 9
11 13
3
4 13
6 14
7 12
3
7 8
4 9
5 9
6
3 11
8 10
3 12
3 11
2 5
6 13
7
8 9
5 8
9 10
3 15
2 14
1 5
1 11
4
3 12
3 4
7 12
10 15
3
6 12
1 4
2...

output:

-1
-1
10 8 6 
9 5 11 13 3 7 1 
2 4 6 8 12 
4 6 8 
-1
4 8 10 6 2 12 
-1
5 3 7 11 
7 1 3 
-1
-1
-1
7 13 9 3 11 1 5 
2 7 5 9 
5 9 3 1 
-1
-1
-1
-1
-1
1 6 13 8 
13 3 7 9 11 5 
5 1 11 3 7 
-1
-1
8 4 2 6 
-1
14 3 5 12 10 
-1
-1
1 14 5 
3 10 12 5 
8 5 1 
-1
-1
10 4 12 6 8 14 
2 4 8 
-1
-1
-1
-1
8 2 6 12 10...

result:

ok Valid schedules (30684 test cases)

Test #10:

score: 0
Accepted
time: 105ms
memory: 9600kb

input:

30707
3
8 16
9 10
3 19
10
1 10
11 13
13 17
10 16
2 17
11 15
7 16
5 6
7 11
8 9
3
4 20
16 20
11 19
7
2 16
3 12
13 19
7 20
12 15
2 6
1 18
7
8 15
5 9
7 16
10 16
13 16
3 16
5 9
4
2 18
16 20
14 18
10 20
5
2 17
9 15
8 14
8 17
13 17
7
4 5
2 19
13 14
5 15
13 14
3 6
8 16
8
14 18
7 20
5 19
10 18
2 13
7 8
5 9
1...

output:

11 9 3 
-1
4 16 12 
7 5 15 9 13 3 1 
9 5 11 13 15 3 7 
2 16 14 11 
2 11 9 13 15 
-1
15 17 9 11 3 7 5 13 
7 9 5 
3 7 1 
-1
8 6 2 
3 7 19 5 9 11 
3 7 13 1 5 9 11 
11 3 9 17 15 19 5 1 13 7 
7 5 11 9 3 
8 10 3 12 
5 15 3 1 7 
-1
3 7 19 11 9 13 5 1 17 15 
8 4 2 
12 18 10 8 4 14 6 16 2 
17 12 10 5 
16 6 1...

result:

ok Valid schedules (30707 test cases)

Test #11:

score: 0
Accepted
time: 87ms
memory: 9676kb

input:

22169
9
7 8
7 17
4 20
7 12
2 4
14 19
4 10
2 16
10 17
6
6 8
8 12
4 8
9 19
14 17
2 18
13
9 17
3 12
10 16
9 12
2 5
3 13
6 10
10 13
12 14
14 15
15 18
16 20
9 11
7
6 9
4 11
5 7
2 5
3 13
4 13
10 18
6
16 17
3 17
2 19
5 16
10 14
5 15
9
11 16
4 18
12 20
14 20
1 7
16 18
4 17
5 19
9 17
10
2 8
1 14
2 18
10 17
5...

output:

7 13 19 9 3 17 5 11 15 
6 8 4 10 14 2 
-1
8 4 6 2 10 12 14 
16 4 2 8 10 6 
11 7 15 19 1 17 5 13 9 
-1
-1
1 11 9 15 17 5 3 
2 16 18 14 
-1
-1
-1
-1
-1
7 9 15 1 11 13 5 
14 5 7 
-1
-1
7 11 9 17 5 
9 17 11 
-1
-1
-1
-1
-1
10 6 8 2 12 4 16 
-1
-1
-1
-1
15 9 7 1 5 11 13 3 17 
6 8 10 4 2 
-1
-1
6 10 4 12 ...

result:

ok Valid schedules (22169 test cases)

Test #12:

score: 0
Accepted
time: 123ms
memory: 9808kb

input:

17323
16
13 29
14 16
3 12
21 32
2 33
10 33
3 9
34 40
19 35
26 35
18 21
22 23
8 32
12 32
6 31
34 40
10
7 10
34 37
28 31
7 33
9 26
19 26
29 32
6 31
16 25
23 34
17
8 35
1 26
4 10
16 31
13 22
23 34
3 37
30 32
7 33
21 30
22 26
8 25
13 28
6 9
9 22
9 11
2 40
3
6 30
1 18
13 18
9
5 11
19 33
20 27
24 27
14 40...

output:

16 14 6 24 2 20 4 34 26 28 18 22 10 12 8 36 
8 35 29 12 10 20 31 6 16 24 
29 1 5 19 13 27 3 31 25 21 23 15 17 7 11 9 33 
7 1 13 
6 23 21 25 15 10 29 19 4 
2 24 18 30 8 20 14 22 6 26 32 28 12 34 16 10 4 
33 9 13 3 7 11 15 1 17 5 31 
15 31 19 6 13 23 17 29 8 2 25 35 37 21 10 4 33 27 
13 29 35 17 25 23...

result:

ok Valid schedules (17323 test cases)

Test #13:

score: 0
Accepted
time: 127ms
memory: 9936kb

input:

12177
14
10 24
8 50
1 19
28 46
25 40
3 56
16 59
16 59
9 51
11 44
9 45
11 45
8 44
12 49
9
18 42
37 58
7 43
2 20
18 38
20 36
21 42
5 56
10 24
8
55 58
54 58
16 48
33 50
25 47
1 56
3 25
33 43
6
53 54
5 40
43 53
7 42
46 57
20 32
25
50 55
18 32
27 36
16 25
21 34
24 40
23 26
37 56
4 47
7 53
19 28
14 58
27 ...

output:

10 8 1 28 26 3 16 18 12 14 20 22 24 30 
22 37 8 2 18 20 24 6 10 
56 54 16 33 26 1 3 35 
53 6 43 8 47 21 
51 21 35 17 25 37 23 43 5 7 19 49 29 31 1 13 33 9 27 39 45 41 11 47 15 
11 35 21 49 17 33 47 37 15 9 27 31 2 4 13 25 23 19 
-1
26 20 8 30 12 10 46 32 14 34 38 42 2 6 24 50 18 28 48 36 22 4 16 40 ...

result:

ok Valid schedules (12177 test cases)

Test #14:

score: 0
Accepted
time: 135ms
memory: 9808kb

input:

9294
15
58 79
50 69
15 58
53 63
3 74
5 55
11 15
36 45
17 35
2 21
61 78
38 78
25 64
30 55
44 54
39
23 80
55 72
7 48
8 72
15 30
17 71
5 48
12 20
30 70
2 5
23 46
29 70
12 50
57 74
36 71
15 50
47 80
35 66
45 67
46 74
7 28
25 39
57 58
23 61
24 77
26 71
9 14
1 2
4 23
50 74
9 54
25 35
72 79
66 77
55 62
7 1...

output:

59 51 15 53 4 6 12 36 17 2 61 38 25 31 44 
75 59 17 61 15 47 19 13 41 3 23 43 29 63 51 31 77 39 45 65 11 27 57 35 69 53 9 1 5 67 33 25 73 71 55 7 37 21 49 
26 54 4 28 35 14 59 16 10 41 8 37 18 46 6 52 12 2 
17 23 33 11 38 
35 7 17 51 55 25 21 71 39 45 5 41 59 33 13 43 65 37 47 53 9 15 23 29 27 31 61...

result:

ok Valid schedules (9294 test cases)

Test #15:

score: 0
Accepted
time: 144ms
memory: 9816kb

input:

7519
43
53 66
4 96
51 76
5 27
19 51
6 99
23 40
74 94
15 44
23 56
86 91
28 53
37 90
52 93
31 33
30 49
41 92
12 20
77 99
13 75
48 77
12 45
46 51
7 41
32 52
27 56
31 60
1 74
5 79
9 82
11 12
5 29
41 89
60 98
17 33
79 95
14 68
42 43
33 43
13 63
8 62
47 52
18 43
19
53 75
17 92
50 70
30 94
31 81
11 87
21 5...

output:

54 78 60 5 26 84 24 76 16 38 86 28 70 74 32 30 72 14 88 58 62 22 46 9 36 40 44 1 64 66 11 7 68 82 18 80 56 42 34 52 50 48 20 
54 17 50 38 32 11 22 88 77 28 30 15 40 34 24 26 56 46 36 
8 75 23 32 10 21 
53 79 44 38 26 
82 42 10 18 48 30 68 34 84 66 70 8 90 22 12 6 16 50 36 28 4 24 20 38 2 54 40 60 62...

result:

ok Valid schedules (7519 test cases)

Test #16:

score: 0
Accepted
time: 202ms
memory: 9940kb

input:

1996
24
86 598
99 140
1 344
628 731
306 375
55 291
356 423
419 573
134 799
620 692
23 712
419 729
360 590
110 390
447 587
134 913
79 657
91 941
50 186
265 495
487 590
200 671
448 975
117 856
61
526 700
99 217
132 216
371 569
410 457
740 747
337 359
494 545
143 816
257 379
662 1000
888 990
244 910
25...

output:

87 100 1 629 306 56 357 420 134 620 24 422 360 110 448 136 79 91 50 266 488 200 450 118 
527 100 133 372 410 740 338 495 143 258 662 888 244 254 269 359 87 279 36 390 481 116 600 424 237 150 85 783 26 226 493 591 301 421 277 250 59 704 576 184 83 92 589 111 232 252 34 334 388 540 894 370 102 293 13 ...

result:

ok Valid schedules (1996 test cases)

Test #17:

score: 0
Accepted
time: 239ms
memory: 12716kb

input:

208
462
8802 9853
6755 7630
6279 7121
1757 5917
5767 9505
3815 6959
1723 7664
5641 6293
3715 4201
986 2197
3891 5659
913 5816
1685 7980
4016 9773
112 6287
1493 9638
2164 7990
4469 6073
1344 7859
3783 5912
3801 7713
5272 7457
774 3781
5278 7372
1801 6123
3686 7748
418 2709
4256 5434
4174 6445
2305 65...

output:

8803 6757 6280 1762 5768 3815 1724 5642 3716 986 3891 913 1686 4017 113 1493 2165 4469 1344 3783 3802 5272 775 5278 1802 3686 418 4256 4175 2306 5932 3473 5976 4149 1863 1328 2582 1656 3162 753 5505 2733 655 5040 5224 5706 1290 6692 2011 4782 6246 4625 7541 3740 1907 7552 6132 184 2845 1546 3390 370...

result:

ok Valid schedules (208 test cases)

Test #18:

score: 0
Accepted
time: 321ms
memory: 18896kb

input:

19
2769
32680 50143
36298 53385
17551 80993
4916 96505
20612 72661
21361 73134
45269 73502
18572 40384
46889 51157
57224 72952
27276 73349
64280 66390
9584 18848
14978 28973
65872 66617
58434 75613
18974 73703
16099 63152
14461 37982
25905 90822
46537 47016
15623 54587
36876 70526
12146 27017
77702 ...

output:

32681 36298 17552 4916 20613 21361 45270 18572 46889 57225 27277 64280 9585 14978 65873 58435 18977 16101 14462 25905 46537 15623 36876 12147 77702 23161 24469 57839 22000 8133 44319 3550 66786 15190 14040 58396 75962 27728 15454 7533 28525 70838 33983 38928 41054 1076 8483 56248 25342 45435 23333 3...

result:

ok Valid schedules (19 test cases)

Test #19:

score: 0
Accepted
time: 408ms
memory: 32164kb

input:

7
49453
73303 133761
70878 83502
285 193719
32429 143928
971 48118
23601 67888
9807 99900
33818 146007
138415 194070
174895 180756
4580 85434
110236 184566
18374 45047
18354 178112
24478 79705
94705 166592
107968 168537
20024 138355
170583 181920
39888 181365
16596 107299
82582 109867
44773 54862
18...

output:

73304 70878 404 32434 972 23602 9814 33820 138419 174895 4580 110236 18374 18366 24478 94708 107968 20024 170584 39888 16600 82582 44776 18710 86230 41592 80210 69566 45200 45920 1868 10230 29040 18430 36408 102412 5996 180466 78204 25698 76964 113482 87814 48678 66398 107864 45336 4606 141673 16761...

result:

ok Valid schedules (7 test cases)

Test #20:

score: 0
Accepted
time: 420ms
memory: 35692kb

input:

5
3538
64567 206572
221341 260487
42137 276255
190113 234239
5489 43714
131726 195290
42875 103293
229450 275537
290863 296669
31024 233198
131667 253945
73820 101905
156410 265901
31236 49977
61411 162791
249562 286149
19549 167528
163635 196271
116410 213942
77372 162420
17656 49614
35527 98402
13...

output:

64568 221342 42137 190113 5489 131727 42876 229450 290864 31024 131668 73821 156411 31236 61412 249563 19549 163635 116410 77373 17656 35528 138984 79639 81473 115063 83748 16367 147380 9903 85395 145547 110816 149176 55679 134703 166854 143688 95669 102957 15150 129858 127859 65548 90350 236217 773...

result:

ok Valid schedules (5 test cases)

Test #21:

score: 0
Accepted
time: 754ms
memory: 85240kb

input:

1
199999
666207 952718
266065 525310
679153 900733
157458 891103
191505 496106
298849 872359
345708 999308
24390 286298
558629 654446
337554 895213
705035 877047
160758 826972
5935 119784
35199 973880
254144 803824
80579 340826
437122 664725
875372 932327
365531 999922
7677 506012
633193 990771
7128...

output:

666208 266066 679154 157466 191506 298850 345711 24392 558629 337557 705036 160758 5936 35210 254148 80580 437123 875372 365531 7678 633194 712829 456157 501520 104452 575016 241952 97700 425263 476636 5076 476351 167832 441862 178878 151410 348050 13836 474368 334632 68020 48978 740169 263240 44603...

result:

ok Valid schedules (1 test case)

Test #22:

score: 0
Accepted
time: 317ms
memory: 69568kb

input:

1
200000
96201 191534
64043 107243
194520 231877
123324 246330
38611 187191
42082 120245
9411 47731
122421 149212
126588 154325
22106 268424
184282 228837
25171 205513
65439 187880
171530 241447
32964 143287
12396 160393
100 174882
7400 79500
9937 140570
13077 238862
221782 251971
55892 197543
17268...

output:

-1

result:

ok Valid schedules (1 test case)

Test #23:

score: 0
Accepted
time: 491ms
memory: 79676kb

input:

1
200000
212026 437809
383684 439421
19066 381799
72861 120247
96028 160342
129692 175308
57917 111831
32670 353707
99579 102105
114411 374760
241558 464138
120151 425821
179507 188621
422619 462196
293826 314604
117594 274238
338996 461706
268228 349167
473568 479197
89350 342047
188677 417663
9444...

output:

250519 383685 139361 72861 96029 129693 57917 77217 99579 125097 303523 226991 179507 422621 293827 117595 339001 268229 473569 89351 211339 99839 58735 87897 276885 55159 357619 193573 34511 280551 264657 176021 12123 133529 291415 92175 146137 153811 343571 141467 67839 446417 42553 44357 33611 12...

result:

ok Valid schedules (1 test case)

Test #24:

score: 0
Accepted
time: 644ms
memory: 82192kb

input:

1
200000
314839 586547
150074 588047
557594 571722
53618 573587
285242 403779
452972 504836
128027 146954
309785 712369
353681 420817
145794 656331
25881 307397
188386 501115
2334 733935
301423 442696
109848 497333
17545 425545
15224 599154
533343 632796
136923 600040
237420 411817
262523 663268
241...

output:

314839 150095 557595 53753 285245 452973 128027 309787 353681 145845 25885 188387 59375 301423 109855 17545 15263 533343 136923 237421 262525 24101 186667 120633 244391 23923 319503 245695 350849 219353 227835 516649 172463 17061 74147 472791 329753 306507 362071 484591 134205 333211 592701 318873 2...

result:

ok Valid schedules (1 test case)

Test #25:

score: 0
Accepted
time: 616ms
memory: 85160kb

input:

1
200000
248061 494228
88457 292570
227749 346825
128481 557695
408553 493979
281015 314394
59107 505690
437851 912551
564718 568902
548368 824358
213305 761301
182345 908657
672078 824881
557305 561073
23229 105568
520018 669100
265507 829401
661766 759522
201836 870255
303813 632983
81431 421633
4...

output:

248062 88458 227750 128482 408554 281016 59108 437855 564719 548369 213306 182366 672079 557306 23230 520019 265508 661766 201836 303814 81432 413016 253946 174614 463574 108230 588546 341548 335540 200358 226192 870092 628535 321808 593445 43530 113730 385325 711300 290878 342509 429286 459719 5904...

result:

ok Valid schedules (1 test case)

Test #26:

score: 0
Accepted
time: 94ms
memory: 9636kb

input:

66699
4
27629 959089
417747 841054
831132 962244
539977 731760
2
208335 793860
833153 868833
4
740936 791894
102137 678337
763178 858292
70628 611437
3
381865 732381
296775 846619
107414 471208
2
473935 937310
235151 532769
4
639792 944903
758543 894716
214300 367006
84082 841284
2
226688 284384
418...

output:

27629 417748 831133 539977 
208335 833154 
740936 102138 763179 70628 
381865 296776 107414 
473936 235151 
639792 758544 214301 84082 
226689 41827 
387113 70996 473673 318533 
131480 103869 577296 318966 
348129 452247 195843 
48040 522656 575726 
315936 52526 325038 816644 
4869 273283 491549 430...

result:

ok Valid schedules (66699 test cases)

Test #27:

score: 0
Accepted
time: 97ms
memory: 9808kb

input:

57172
3
1 12
1 2
1 12
4
5 11
1 6
5 12
2 4
3
1 7
3 10
4 11
2
1 12
4 11
3
1 10
3 10
3 8
2
2 7
3 6
5
1 9
3 7
4 6
4 12
4 9
2
3 11
1 8
4
1 12
1 9
1 6
3 11
4
6 11
5 6
2 7
1 9
5
9 12
1 11
1 9
7 12
1 10
3
4 8
1 6
5 11
5
1 10
2 7
4 10
1 8
7 10
2
3 12
2 4
3
2 6
5 7
1 8
5
5 10
1 11
1 8
1 10
2 10
2
4 8
2 9
2
5 ...

output:

3 1 5 
5 1 7 3 
1 3 5 
1 5 
1 5 3 
2 4 
1 3 5 9 7 
3 1 
7 3 1 5 
7 5 3 1 
9 5 1 7 3 
5 1 7 
5 3 7 1 9 
4 2 
3 5 1 
5 9 1 3 7 
4 2 
6 1 
1 5 7 9 3 
4 6 
3 1 
1 5 3 9 7 
3 1 7 5 
9 3 1 7 5 
1 6 
3 5 1 7 9 
3 7 9 5 1 
5 9 3 7 1 
1 5 7 3 9 
7 3 5 1 
5 9 1 7 3 
3 1 5 
6 1 
1 5 3 
1 3 7 9 5 
6 4 
8 1 6 
1...

result:

ok Valid schedules (57172 test cases)

Test #28:

score: 0
Accepted
time: 98ms
memory: 9812kb

input:

44461
3
1 6
1 3
4 10
5
4 14
1 13
1 7
5 10
4 12
5
5 12
1 10
1 13
3 9
1 7
3
6 9
1 9
3 6
3
2 9
1 7
3 6
4
3 9
6 11
1 6
2 9
5
7 12
9 12
1 10
3 4
1 6
5
2 13
2 13
1 11
3 7
3 12
4
1 6
1 14
2 14
1 7
4
5 8
5 13
1 10
5 7
3
1 12
3 12
2 5
6
2 12
8 14
3 10
1 13
2 10
1 9
6
1 14
7 13
1 8
5 14
2 7
1 7
3
2 8
3 10
2 6...

output:

3 1 5 
9 3 1 5 7 
7 5 9 3 1 
7 1 3 
5 1 3 
3 7 1 5 
7 9 5 3 1 
7 9 1 3 5 
1 5 7 3 
7 9 2 5 
1 5 3 
7 11 3 9 5 1 
9 7 5 11 3 1 
4 6 2 
1 7 3 5 9 11 
1 9 3 5 7 
1 5 9 7 11 3 
1 7 3 5 
6 8 2 4 
7 9 1 5 3 
9 7 3 5 1 
5 9 3 1 
5 9 7 11 1 3 
3 7 9 1 5 
9 7 5 3 1 
4 6 2 8 
9 11 1 3 7 5 
1 5 11 9 7 3 
3 1 5...

result:

ok Valid schedules (44461 test cases)

Test #29:

score: 0
Accepted
time: 97ms
memory: 9808kb

input:

36476
4
2 11
8 9
5 9
1 16
6
4 10
1 9
1 11
5 8
2 9
8 16
4
8 14
2 4
1 9
3 7
4
4 8
1 8
4 9
3 13
7
3 8
2 11
2 13
2 5
2 15
9 16
1 3
4
5 14
1 5
7 13
3 10
7
1 16
1 9
1 15
5 15
5 13
10 12
2 9
5
9 15
1 2
3 12
7 11
2 12
7
3 16
4 8
1 13
1 6
5 15
3 16
9 13
4
1 15
2 15
5 6
1 13
6
3 16
2 15
1 5
6 15
3 5
9 15
6
2 ...

output:

2 8 6 4 
7 1 9 5 3 11 
9 3 1 5 
5 1 7 3 
5 7 9 3 11 13 1 
5 1 7 3 
13 1 7 9 5 11 3 
9 1 3 7 5 
11 5 3 1 7 13 9 
1 3 5 7 
11 5 1 7 3 9 
3 9 11 5 7 1 
5 9 7 1 3 
5 7 1 3 
1 5 7 3 
3 1 9 5 7 
7 1 3 9 
7 3 1 9 5 
1 9 7 3 11 5 
5 7 3 11 9 1 
3 9 7 11 1 5 
5 1 3 9 7 
9 13 5 11 1 3 7 
9 5 7 1 3 13 11 
3 1 ...

result:

ok Valid schedules (36476 test cases)

Test #30:

score: 0
Accepted
time: 99ms
memory: 9804kb

input:

28544
7
5 11
6 17
4 12
4 13
1 17
4 15
3 12
8
8 18
7 14
6 17
2 16
5 11
2 13
1 8
1 12
7
1 15
3 13
2 16
6 11
7 20
1 8
6 15
6
2 12
1 10
1 11
3 19
8 20
5 20
9
1 11
2 17
2 15
1 12
11 20
13 19
3 4
1 9
3 10
9
3 18
1 12
1 17
1 8
8 17
6 15
13 16
2 20
10 18
9
10 18
3 12
5 12
7 17
1 17
2 15
6 15
7 19
1 18
8
2 4...

output:

5 13 7 9 1 11 3 
15 9 13 11 5 7 1 3 
5 3 11 7 13 1 9 
5 1 3 7 9 11 
7 13 11 9 17 15 3 1 5 
11 3 5 1 9 7 13 17 15 
13 3 5 11 1 7 9 17 15 
3 7 13 11 15 9 1 5 
1 5 3 7 9 
5 3 1 9 7 
5 11 13 3 7 1 9 
1 5 7 9 11 3 
7 5 9 1 3 11 
1 15 9 3 11 5 7 13 
9 11 7 1 13 15 3 5 
11 1 7 3 9 5 13 
5 1 3 7 9 11 13 
1 ...

result:

ok Valid schedules (28544 test cases)

Test #31:

score: 0
Accepted
time: 106ms
memory: 9812kb

input:

13360
20
4 31
20 31
9 27
30 40
25 34
24 36
27 41
19 41
10 35
10 21
3 36
23 36
1 32
4 21
5 37
3 15
15 32
5 27
35 38
3 29
20
31 35
1 29
15 29
7 25
35 37
1 29
5 21
18 31
9 42
3 31
5 41
21 38
28 35
2 24
4 41
4 16
13 29
9 41
4 23
19 42
13
3 29
6 25
5 19
4 15
2 17
4 29
12 21
4 37
13 30
6 37
18 30
1 41
10 ...

output:

15 21 9 33 25 27 37 39 19 11 23 29 1 5 31 3 17 7 35 13 
31 1 15 11 35 13 7 19 37 21 25 23 29 3 27 5 17 33 9 39 
15 9 7 5 3 17 13 23 19 25 21 1 11 
25 19 27 3 7 13 29 9 5 17 21 11 15 1 23 
7 9 5 19 11 15 1 3 13 17 
19 17 5 21 23 1 15 3 7 9 13 11 
13 1 19 5 17 21 15 11 9 7 3 23 
5 11 9 13 3 15 17 1 7 ...

result:

ok Valid schedules (13360 test cases)

Test #32:

score: 0
Accepted
time: 143ms
memory: 9824kb

input:

3314
88
113 121
110 179
29 134
8 136
10 180
50 187
4 200
15 174
51 132
9 66
16 169
39 200
56 176
7 40
97 181
104 166
3 114
18 189
43 107
48 183
113 184
11 160
18 61
104 134
15 101
51 193
24 49
36 171
2 125
88 115
8 81
55 182
7 199
53 136
49 159
49 67
75 174
30 71
4 152
70 200
20 74
18 195
131 192
10...

output:

113 119 55 57 123 137 171 99 51 9 91 173 111 7 125 107 33 141 43 129 135 83 19 105 27 145 25 97 39 89 13 127 163 59 81 49 101 31 67 175 23 153 143 109 165 73 157 147 131 3 65 103 37 93 151 87 45 95 21 35 11 79 161 121 155 133 139 5 29 115 167 169 69 117 53 15 77 159 17 149 1 71 61 41 85 75 47 63 
3 ...

result:

ok Valid schedules (3314 test cases)

Test #33:

score: 0
Accepted
time: 186ms
memory: 10348kb

input:

387
955
413 1866
243 1214
202 1969
216 1988
73 741
126 1666
63 1707
1677 1958
430 1836
895 1486
711 1444
26 1053
165 1044
1616 1674
306 1580
1521 1698
1020 1766
262 1086
329 691
71 1599
21 782
654 1789
133 1349
423 1513
135 1906
19 1821
1315 1830
179 1877
366 1481
70 1403
6 1845
937 2000
113 1613
24...

output:

1421 299 1787 1855 73 935 1009 1735 1317 895 711 133 171 1617 767 1521 1151 263 329 803 33 1195 417 667 1529 1279 1315 1437 631 499 1355 1901 829 287 847 1613 149 399 885 609 1757 835 855 605 1797 687 157 1805 617 1189 1755 1005 201 377 1895 79 709 1849 1161 1325 1183 1003 869 533 913 1293 1337 1259...

result:

ok Valid schedules (387 test cases)

Test #34:

score: 0
Accepted
time: 217ms
memory: 13328kb

input:

33
2933
1368 16952
5280 16566
2652 11887
10035 12268
1548 11337
100 495
4636 14619
1376 17631
2176 18183
6361 15482
1736 11724
3384 15583
8 9682
987 18640
5081 19982
1035 11699
829 17812
572 17013
3217 8690
4682 10580
4460 15877
2776 13450
2240 19194
4053 19668
2344 6281
485 13832
938 12002
7186 166...

output:

1369 5281 2659 10035 1551 101 4637 1377 2177 6361 1737 3385 11 991 5081 1035 837 743 3217 4683 4461 2777 2241 4053 2345 749 939 7187 751 753 4253 1645 1155 10574 11023 5073 3349 1021 1791 8542 5345 235 767 513 163 2645 757 873 761 1 765 3121 2407 893 7962 1447 13662 831 6217 4877 503 405 561 1581 58...

result:

ok Valid schedules (33 test cases)

Test #35:

score: 0
Accepted
time: 294ms
memory: 35612kb

input:

3
61998
14069 145627
24631 144561
8736 57795
20150 193017
7236 170581
47616 93168
41304 195341
680 123958
44227 195363
53571 140979
7045 60469
24912 97853
1179 60801
36637 148430
19743 54827
169 165243
32390 153757
17935 186101
58772 100328
18939 152065
2779 182740
2981 9159
47472 130091
13777 18551...

output:

63793 62555 8739 109865 93253 47617 109871 39813 109873 58441 7047 24913 2681 66995 19743 86869 73419 109875 58773 71457 106387 2981 47481 109365 68491 74343 98991 96017 99861 106273 39875 83199 23323 76311 94467 20311 16715 29005 5231 25831 109877 55169 109879 19541 105333 76799 82797 17101 33873 5...

result:

ok Valid schedules (3 test cases)

Test #36:

score: 0
Accepted
time: 277ms
memory: 55044kb

input:

1
135234
85512 209169
189226 278946
62760 307609
6885 169772
83503 397703
4639 285739
207376 360410
19548 169381
50364 143928
62166 339294
6040 242927
177905 363720
83421 274195
120403 303625
54605 145905
43993 125786
22770 254386
4292 383447
11707 162514
120798 273484
32451 306093
136250 213900
202...

output:

85513 189227 152733 21445 267843 123959 223299 21247 50365 195779 74677 227563 109191 147297 54605 43995 86633 251515 18045 120801 150839 136251 20293 151305 152019 198409 80299 197235 218261 13345 212317 184203 219555 170981 159509 204405 52759 231857 42659 226197 80369 71959 131679 188001 234699 1...

result:

ok Valid schedules (1 test case)

Test #37:

score: 0
Accepted
time: 386ms
memory: 72584kb

input:

1
195939
61071 372393
45305 399328
74041 363710
235664 252319
23056 386144
85337 372890
31967 359799
6654 254335
2133 324087
12406 387073
335 144719
137527 368350
58272 322108
321920 390918
22112 378967
36688 82650
2231 277651
159551 397599
13749 192736
95467 393745
6664 391933
56040 132529
56492 18...

output:

294709 389181 271063 235665 338093 296031 261065 85715 185245 341389 11763 283607 181851 355815 314449 36689 113567 382341 34397 366817 359827 56041 56493 375323 165049 389429 289203 327213 36363 273653 248863 345731 112609 361705 53119 183389 146527 84723 15855 293661 269529 341753 217283 281721 27...

result:

ok Valid schedules (1 test case)

Test #38:

score: 0
Accepted
time: 400ms
memory: 73492kb

input:

1
199999
106449 251696
76616 262687
97217 338902
58380 380547
94492 316012
109531 392825
246413 344535
16657 35258
69722 316567
61129 381465
9671 369100
110607 245704
25445 397502
11881 348493
304136 397954
86892 381967
81356 329422
128170 389159
29632 172656
98378 388670
95197 286189
183541 245815
...

output:

106451 94925 214283 319429 171049 363311 246413 16659 172097 322389 285489 110611 384743 235263 387057 324089 195833 349021 29633 347255 124445 183541 244177 19695 121331 392525 165701 267391 66225 382779 333777 10943 398369 351213 387553 241171 381073 10311 240249 158139 73027 2603 147005 166915 32...

result:

ok Valid schedules (1 test case)

Test #39:

score: 0
Accepted
time: 404ms
memory: 75152kb

input:

1
200000
102943 390699
49394 358426
270755 384555
52799 227296
88093 340705
128995 364966
136352 359097
1013 126358
154135 353021
85576 203812
321855 368556
226434 305723
14121 150109
160674 226395
9876 284046
130691 354714
13299 42076
255161 316201
233998 319770
132156 284042
6204 141266
271185 317...

output:

354639 258529 332483 60057 218301 275053 260197 6341 245657 85577 321855 226435 14125 160675 121713 249575 13299 255161 233999 132157 10613 271185 132219 125557 243849 351861 69845 203183 286687 301607 165901 54961 116753 321763 189599 141515 55445 177329 274769 258273 221061 254153 187695 97673 146...

result:

ok Valid schedules (1 test case)

Test #40:

score: 0
Accepted
time: 456ms
memory: 82988kb

input:

1
200000
423669 939935
126496 938281
75834 353068
206313 620378
91654 858602
27239 207128
21974 766776
49222 364553
98606 690988
296638 689902
109647 800954
361150 840841
92553 984099
468742 875457
35090 677204
76715 505858
128788 491021
123978 409231
190237 661631
300071 707065
11664 820092
246934 ...

output:

423669 126497 75835 206313 91659 27239 74847 49223 98607 296641 109647 361151 92569 468743 74849 76717 128789 123979 190239 300071 74851 246935 162947 86213 13375 74853 101119 253287 52941 31237 187725 74855 128937 85185 6369 65819 148605 384539 369185 79217 68449 114269 74861 204897 163163 230467 1...

result:

ok Valid schedules (1 test case)

Test #41:

score: 0
Accepted
time: 269ms
memory: 63932kb

input:

1
200000
2 3
999999 1000000
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111...

output:

2 999999 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 17...

result:

ok Valid schedules (1 test case)

Test #42:

score: 0
Accepted
time: 290ms
memory: 65288kb

input:

1
200000
999998 999999
1 2
999996 1000000
999994 1000000
999992 1000000
999990 1000000
999988 1000000
999986 1000000
999984 1000000
999982 1000000
999980 1000000
999978 1000000
999976 1000000
999974 1000000
999972 1000000
999970 1000000
999968 1000000
999966 1000000
999964 1000000
999962 1000000
999...

output:

999998 1 999996 999994 999992 999990 999988 999986 999984 999982 999980 999978 999976 999974 999972 999970 999968 999966 999964 999962 999960 999958 999956 999954 999952 999950 999948 999946 999944 999942 999940 999938 999936 999934 999932 999930 999928 999926 999924 999922 999920 999918 999916 9999...

result:

ok Valid schedules (1 test case)

Test #43:

score: -100
Wrong Answer
time: 216ms
memory: 10384kb

input:

385
382
482 491
700 710
716 741
608 610
720 734
748 754
298 309
313 320
445 446
313 326
250 259
693 695
156 160
801 802
371 372
214 227
560 572
566 574
66 69
234 237
597 600
516 533
13 17
358 361
128 138
406 410
718 726
427 436
72 78
456 459
597 599
774 781
818 830
179 197
338 346
750 753
222 227
12...

output:

-1
183 247 332 61 15 201 156 117 341 112 256 269 55 121 187 394 53 422 330 381 176 373 205 91 371 241 277 266 32 93 222 228 286 78 390 272 172 355 369 131 103 346 296 254 413 215 9 207 349 11 36 419 174 23 87 98 353 126 281 166 38 80 305 383 339 85 288 179 168 185 377 195 343 230 233 170 398 425 212...

result:

wrong answer jury found an answer, participant did not (test case 1)