QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#347556#7530. Go Play Wall-nut Bowling!ucup-team1209AC ✓837ms151800kbC++204.3kb2024-03-09 14:15:032024-03-09 14:15:03

Judging History

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

  • [2024-03-09 14:15:03]
  • 评测
  • 测评结果:AC
  • 用时:837ms
  • 内存:151800kb
  • [2024-03-09 14:15:03]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using ll = long long;
using u64 = unsigned long long;
void IOinit() {
	std::ios::sync_with_stdio(false), cin.tie(0);
#ifdef zqj
	freopen("1.in", "r", stdin);
#endif
}
const int N = 300005;
const int M = N * 2;

int fa[M], son[M][2], min[M], val[M], add[M];
int size[M];

std::vector<int> chk;

void put(int x, int v) {
	if(!x) return ;
	min[x] += v;
	val[x] += v;
	add[x] += v;
}
int get(int x) {
	return son[fa[x]][1] == x;
}
void update(int x) {
	min[x] = val[x];
	size[x] = size[son[x][0]] + 1 + size[son[x][1]];
	if(son[x][0] && min[son[x][0]] < min[x]) min[x] = min[son[x][0]];
	if(son[x][1] && min[son[x][1]] < min[x]) min[x] = min[son[x][1]];
}
void pushdown(int x) {
	put(son[x][0], add[x]);
	put(son[x][1], add[x]);
	add[x] = 0;
}
void rotate(int x) {
	int y = fa[x], z = fa[y], b = get(x);
	if(z) son[z][get(y)] = x;
	son[y][b] = son[x][!b], son[x][!b] = y;
	fa[son[y][b]] = y, fa[y] = x, fa[x] = z;
	update(y);
}
void down(int x) {
	if(!x) return ;
	down(fa[x]), pushdown(x);
}
void splay(int x) {
	down(x);
	for(;fa[x];rotate(x)) if(fa[fa[x]])
		rotate(get(x) ^ get(fa[x]) ? x : fa[x]);
	update(x);
}
void dfs(int x) {
	if(!x || min[x] > 0) return ;
	pushdown(x);
	dfs(son[x][0]);
	if(val[x] <= 0) {
		chk.push_back(x / 2);
	}
	dfs(son[x][1]);
}
int sub(int x) {
	splay(x), val[x] -= 1, update(x);
	if(val[x] <= 0) chk.push_back(x / 2);
	int ans = 1 + size[son[x][1]];
	put(son[x][1], -1);
	dfs(son[x][1]);
	return ans;
}
std::unordered_map<int, std::map<int, int>> map[3];

int dead[N], r[N], c[N];
void set(int a, int b) {
	if(a) {
		splay(a);
		fa[son[a][1]] = 0;
		son[a][1] = 0;
		update(a);
	}
	if(b) {
		splay(b);
		fa[son[b][0]] = 0;
		son[b][0] = 0;
		update(b);
	}
	if(a && b) {
		son[a][1] = b;
		fa[b] = a;
		update(a);
	}
}
void ins(std::map<int, int> & m, int p, int v) {
	auto [iter, succ] = m.emplace(p, v);
	if(next(iter) != m.end()) {
		set(v, next(iter) -> second ^ 1);
	}
	if(iter != m.begin()) {
		set(prev(iter) -> second, v ^ 1);
	}
}
void del(std::map<int, int> & m, int p, int v) {
	auto iter = m.find(p);
	int x = 0, y = 0;
	if(next(iter) != m.end()) {
		y = next(iter) -> second ^ 1;
	}
	if(iter != m.begin()) {
		x = prev(iter) -> second;
	}
	set(x, y);
	m.erase(iter);
}
void kill(int x) {
	int r = ::r[x], c = ::c[x];
	dead[x] = 1;
	del(map[1][r + c], -r + c, x * 2);
	del(map[2][-r + c], r + c, x * 2 + 1);
}
using pr = std::pair<int, int>;

std::priority_queue<pr, std::vector<pr>, std::greater<pr>> Q;

int main() {
#ifdef zqj
	freopen("1.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false), cin.tie(0);
	for(auto & x : map) x.rehash(N * 2);
	int M, N, q, sum_t = 0, id = 0;
	cin >> M >> N >> q;
	cout << "stdout ducks" << '\n';
	for(int i = 0;i < q;++i) {
		std::string s;
		cin >> s;
		if(s == "time") {
			int t;
			cin >> t;
			sum_t += t;
			int leave = 0;
			for(;Q.size() && Q.top().first <= sum_t;) {
				auto [_, id] = Q.top(); Q.pop();
				if(!dead[id]) {
					kill(id);
					leave += 1;
				}
			}
			cout << leave << '\n';
		}
		if(s == "deliver") {
			int r, c, s;
			cin >> r >> c >> s;
			c += sum_t;
			auto & mp = map[0][r];
			for(;;) {
				auto iter = mp.lower_bound(c);
				if(iter == mp.end()) {
					cout << 0 << ' ' << 0 << '\n';
					break;
				}
				if(dead[iter -> second]) {
					mp.erase(iter);
					continue;
				}
				int kill_c = 0;
				int bounce = sub(iter -> second * 2 ^ (s > 0));
				for(int x : chk) {
					splay(x * 2);
					splay(x * 2 + 1);
					int hp = val[x * 2] + val[x * 2 + 1];
					if(hp == 1) {
						kill_c += 1;
						kill(x);
					} else {
						val[x * 2] = hp / 2;
						val[x * 2 + 1] = (hp + 1) / 2;
						update(x * 2);
						update(x * 2 + 1);
					}
				}
				chk.clear();
				cout << bounce << ' ' << kill_c << '\n';
				break;
			}
		}
		if(s == "add") {
			int r, c, h;
			cin >> r >> c >> h, h += 1;
			c += sum_t;
			int x = ++ id;
			::r[x] = r;
			::c[x] = c;
			val[x * 2 + 0] = h / 2, update(x * 2);
			val[x * 2 + 1] = (h + 1) / 2, update(x * 2 + 1);
			map[0][r][c] = x;
			ins(map[1][r + c], -r + c, x * 2);
			ins(map[2][-r + c], r + c, x * 2 + 1);
			Q.emplace(c, x);
		}
	//	std::cerr << "finish : " << i << std::endl;
	}
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 23848kb

input:

6 8 23
add 2 4 2
add 3 7 1
add 4 6 3
add 5 3 3
add 6 4 3
deliver 1 1 1
deliver 5 1 1
deliver 5 1 -1
deliver 2 4 1
deliver 5 1 1
time 2
add 4 4 3
deliver 2 1 1
deliver 6 1 -1
time 7
add 2 3 1
add 2 6 1
add 3 3 1
add 4 4 1
deliver 2 5 1
add 3 7 10
deliver 3 2 1
time 5

output:

stdout ducks
0 0
3 0
1 0
3 1
3 2
0
2 1
2 1
1
1 1
2 2
1

result:

ok 23 tokens

Test #2:

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

input:

4 5 51
add 1 3 2
add 1 4 1
add 2 2 1
add 2 4 3
add 2 5 2
time 1
add 3 2 1
add 4 3 3
add 4 4 1
deliver 2 2 -1
deliver 2 2 1
deliver 4 1 1
deliver 4 1 -1
deliver 2 1 1
time 1
add 3 1 2
deliver 3 1 1
deliver 1 1 1
time 1
deliver 4 1 -1
deliver 3 2 1
add 1 3 2
add 3 3 1
add 2 4 3
add 1 5 1
add 3 5 2
del...

output:

stdout ducks
0
1 0
1 0
1 0
1 0
3 3
0
2 1
1 0
2
1 1
0 0
5 2
0 0
2 0
1 1
4 4
0 0
0 0
1 1
0 0
0
3 1
2 2
2
1 0
2 2
1

result:

ok 52 tokens

Test #3:

score: 0
Accepted
time: 5ms
memory: 23788kb

input:

5 5 67
add 1 1 1
add 1 2 2
add 1 3 3
add 1 4 4
add 1 5 5
add 2 1 1
add 2 2 2
add 2 3 3
add 2 4 4
add 2 5 5
add 3 1 1
add 3 2 2
add 3 3 3
add 3 4 4
add 3 5 5
add 4 1 1
add 4 2 2
add 4 3 3
add 4 4 4
add 4 5 5
add 5 1 1
add 5 2 2
add 5 3 3
add 5 4 4
add 5 5 5
deliver 2 1 1
deliver 4 1 1
deliver 1 1 1
d...

output:

stdout ducks
5 1
5 1
5 1
3 0
3 0
5 2
3 1
4 1
5 3
3 0
3 2
2
1 0
2 0
1 0
3 0
3 1
5 3
4 1
2 1
1 0
3 1
3 3
0 0
2 1
4 4
3 1
5
0 0
1 1

result:

ok 60 tokens

Test #4:

score: 0
Accepted
time: 4ms
memory: 25464kb

input:

1 1 1
add 1 1 1000000

output:

stdout ducks

result:

ok 2 tokens

Test #5:

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

input:

1 1 1
deliver 1 1 -1

output:

stdout ducks
0 0

result:

ok 4 tokens

Test #6:

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

input:

1 1 1
time 10000000

output:

stdout ducks
0

result:

ok 3 tokens

Test #7:

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

input:

1 9 60
time 5
add 1 1 1
add 1 2 2
add 1 3 3
add 1 4 4
add 1 5 5
add 1 6 6
add 1 7 7
add 1 8 8
add 1 9 9
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver 1 1 -1
deliver 1 1 1
deliver ...

output:

stdout ducks
0
1 1
1 0
1 1
1 0
1 0
1 1
1 0
1 0
1 0
1 1
1 0
1 0
1 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 1
0 0
0 0
0 0
0 0
0 0

result:

ok 103 tokens

Test #8:

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

input:

9 1 100
time 5
add 1 1 1
add 2 1 2
add 3 1 3
add 4 1 4
add 5 1 5
add 6 1 6
add 7 1 7
add 8 1 8
add 9 1 9
deliver 1 1 1
deliver 1 1 -1
deliver 2 1 1
deliver 2 1 -1
deliver 3 1 1
deliver 3 1 -1
deliver 4 1 1
deliver 4 1 -1
deliver 5 1 1
deliver 5 1 -1
deliver 6 1 1
deliver 6 1 -1
deliver 7 1 1
deliver...

output:

stdout ducks
0
1 1
0 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 0
0 0
0 0
0 0
1 1
0 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
1 0
1 1
1 0
1 0
1 0
1 0
1 0
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
1 0
1 1
1 0
1...

result:

ok 183 tokens

Test #9:

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

input:

10000000 10000000 23
time 10000000
add 3758691 5103157 1000000
add 758691 2103157 1
add 6758691 8103157 10
deliver 1 1 1
deliver 1 1 -1
deliver 10000000 1 1
deliver 10000000 1 -1
deliver 758691 5555555 1
deliver 758691 1111111 1
deliver 758691 500000 -1
deliver 6758691 10000000 1
deliver 6758691 100...

output:

stdout ducks
0
0 0
0 0
0 0
0 0
0 0
2 1
0 0
0 0
0 0
1 0
1 0
0
1
0
1 0
0 0
1
0 0
0 0

result:

ok 37 tokens

Test #10:

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

input:

1644 998 1000
time 3
add 984 275 2
add 646 639 4
add 815 340 1
time 2
add 971 754 4
add 568 923 6
add 347 533 6
deliver 243 117 1
add 984 299 1
deliver 308 624 -1
add 802 104 5
deliver 685 481 1
add 880 351 3
time 9
deliver 919 251 -1
add 308 303 5
time 10
add 581 319 5
time 10
add 971 23 3
time 8
a...

output:

stdout ducks
0
0
0 0
0 0
0 0
0
0 0
0
0
0
0
0 0
1 0
0
0 0
0 0
0 0
1
0 0
0 0
0 0
0 0
1 0
0
0
0
1 0
0 0
0 0
0
0
0
0
1 0
1
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0 0
1 0
0
0 0
0 0
0
0 0
0 0
0 0
0 0
0
0
0 0
1
0
1
1
0
1 0
0
0 0
0 0
0 0
0 0
1
0 0
0
0
0
1 0
2
0 0
0
0
0 0
0 0
0
0 0
1
0
0 0
0 0
0 0
0 0
1 1
2...

result:

ok 1004 tokens

Test #11:

score: 0
Accepted
time: 494ms
memory: 88144kb

input:

4 578311 300000
add 1 200001 300001
add 2 200002 1
add 1 200003 300001
add 2 200004 2
add 1 200005 300001
add 2 200006 3
add 1 200007 300001
add 2 200008 4
add 1 200009 300001
add 2 200010 5
add 1 200011 300001
add 2 200012 6
add 1 200013 300001
add 2 200014 7
add 1 200015 300001
add 2 200016 8
add ...

output:

stdout ducks
199999 1
199997 1
199995 1
199993 1
199991 1
199989 1
199987 1
199985 1
199983 1
199981 1
199979 1
199977 1
199975 1
199973 1
199971 1
199969 1
199967 1
199965 1
199963 1
199961 1
199959 1
199957 1
199955 1
199953 1
199951 1
199949 1
199947 1
199945 1
199943 1
199941 1
199939 1
199937 1...

result:

ok 200002 tokens

Test #12:

score: 0
Accepted
time: 5ms
memory: 23984kb

input:

9 22 10000
add 6 2 6
deliver 1 9 1
deliver 6 5 1
add 2 1 8
deliver 5 10 1
add 3 1 2
deliver 4 3 -1
add 1 5 4
deliver 3 11 -1
add 2 4 7
add 6 7 7
add 5 11 5
add 5 8 4
deliver 7 8 -1
add 5 1 6
deliver 7 11 1
add 5 9 3
deliver 5 6 1
deliver 5 5 1
deliver 1 5 1
add 1 11 7
add 6 10 1
deliver 6 7 1
delive...

output:

stdout ducks
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 0
1 0
2 0
1 0
1 0
0 0
2 0
0 0
1 0
0 0
0 0
2 0
1 0
0 0
1 0
2 1
2 0
2 1
6 1
2 0
1 0
0 0
0 0
2 1
1 0
1 0
1 0
0 0
4 0
0 0
1 0
0 0
0 0
1 0
1 1
2 0
2 0
1 0
2 1
1 0
0 0
1 0
0 0
2 0
1 0
1 0
0 0
0 0
1 0
1 0
2 0
4 0
1 0
1 1
1 0
1 0
1 0
3 0
1 0
1 0
3 0
1 0
4 0
1 1
1 0...

result:

ok 13931 tokens

Test #13:

score: 0
Accepted
time: 3ms
memory: 25996kb

input:

19 148 10000
deliver 2 10 1
deliver 3 8 1
deliver 2 34 1
add 7 67 1
deliver 6 25 1
deliver 1 44 -1
deliver 1 90 1
deliver 4 43 -1
add 5 44 4
deliver 1 49 1
add 5 14 2
deliver 7 49 1
add 4 12 3
deliver 5 35 1
deliver 5 89 -1
deliver 4 32 -1
add 5 26 2
add 4 20 4
add 4 2 5
add 5 84 2
deliver 4 88 -1
d...

output:

stdout ducks
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
1 0
0 0
0 0
0 0
0 0
0 0
1 0
0 0
0 0
0 0
0 0
1 0
1 0
0 0
0 0
1 0
0 0
1 1
0 0
1 0
1 0
1 1
0 0
1 0
0 0
1 0
1 1
0 0
1 1
1 1
0 0
0 0
0 0
1 0
0 0
1 0
0 0
1 0
0 0
1 0
0 0
1 0
0 0
1 0
1 0
0 0
0 0
1 1
2 0
1 0
0 0
0 0
1 0
1 0
2 0
1 0
0 0
1 0
1 1
1 1
2 0
0
1 0
0...

result:

ok 13227 tokens

Test #14:

score: 0
Accepted
time: 213ms
memory: 29728kb

input:

7741469 9773860 300000
deliver 4255914 8270353 -1
deliver 2481646 7383219 -1
deliver 2481646 8270353 -1
add 3368780 7383219 1
add 707378 286147 8
add 3368780 6496085 6
add 3368780 4721817 1
add 707378 2060415 1
deliver 4255914 4721817 1
deliver 1594512 9157487 1
add 4255914 6496085 10
deliver 707378...

output:

stdout ducks
0 0
0 0
0 0
0 0
0 0
1 1
1 1
0 0
1 0
1 0
0 0
1 0
2 1
1 0
1 0
0 0
0 0
1 0
0
0 0
4 2
3 2
1 1
2 0
1 0
2 0
0
1 0
3 0
4 2
1 0
5 1
2 1
2 0
1 0
0 0
1 0
2 0
5 3
0 0
1 0
3 0
2 0
4 1
0 0
1 0
0 0
3 0
0 0
1 0
1 0
3 1
7 2
2 0
1 0
1 0
1 0
3 0
5 0
1 0
4 0
3 0
1 1
1 0
5 2
4
3 0
4 1
2 0
1 0
6 1
4 1
1 0
0...

result:

ok 384787 tokens

Test #15:

score: 0
Accepted
time: 559ms
memory: 75908kb

input:

286225 438644 300000
add 97880 195757 195588
add 49838 99673 256733
add 135469 270938 215078
add 139511 279022 202486
add 95191 190382 225056
add 60937 121874 256422
add 94502 189001 140338
add 29026 58049 230909
add 66836 133669 160130
add 106612 213221 242024
add 69717 139434 252543
add 577 1154 2...

output:

stdout ducks
149999 0
149893 0
149999 0
148392 0
51438 0
122000 0
149746 0
149999 0
149736 0
149999 0
149992 0
146389 0
76694 0
148676 0
149999 0
57907 0
149998 0
149999 0
149451 0
149944 0
143544 0
149997 0
149999 0
149585 0
149999 0
149999 0
149999 0
90633 0
149890 0
149999 0
149921 0
149633 0
148...

result:

ok 299002 tokens

Test #16:

score: 0
Accepted
time: 681ms
memory: 78052kb

input:

211354 363265 300000
add 75239 150478 140000
add 14944 29885 140000
add 49147 98294 140000
add 96887 193774 140000
add 5555 11110 140000
add 134704 269405 140000
add 31959 63918 140000
add 42439 84878 140000
add 148753 297506 140000
add 69522 139041 140000
add 28772 57541 140000
add 95264 190525 140...

output:

stdout ducks
41204 0
54464 0
149999 0
117629 0
149882 0
149999 0
149999 0
149957 0
149999 0
99459 0
134322 0
140934 0
149852 0
149999 0
149998 0
149999 0
149937 0
149998 0
149999 0
149999 0
114597 0
149996 0
149947 0
149999 0
142383 0
149927 0
109085 0
148703 0
121711 0
146772 0
144143 0
139700 0
14...

result:

ok 299002 tokens

Test #17:

score: 0
Accepted
time: 837ms
memory: 78644kb

input:

226225 379503 300000
add 84513 169026 140000
add 122359 244718 140000
add 89261 178522 140000
add 50516 101029 140000
add 142485 284970 140000
add 51848 103693 140000
add 90834 181665 140000
add 68444 136885 140000
add 16347 32694 140000
add 73372 146741 140000
add 40852 81701 140000
add 105040 2100...

output:

stdout ducks
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0
149999 0...

result:

ok 299002 tokens

Test #18:

score: 0
Accepted
time: 828ms
memory: 78888kb

input:

11 637556 300000
add 2 246766 23383
add 2 279584 39792
add 2 365862 82931
add 1 251011 300001
add 1 301035 300001
add 1 210867 300001
add 2 256100 28050
add 1 280727 300001
add 2 338806 69403
add 1 245595 300001
add 1 288699 300001
add 1 323621 300001
add 1 239723 300001
add 1 237611 300001
add 2 38...

output:

stdout ducks
199999 1
199997 1
199995 1
199993 1
199991 1
199989 1
199987 1
199985 1
199983 1
199981 1
199979 1
199977 1
199975 1
199973 1
199971 1
199969 1
199967 1
199965 1
199963 1
199961 1
199959 1
199957 1
199955 1
199953 1
199951 1
199949 1
199947 1
199945 1
199943 1
199941 1
199939 1
199937 1...

result:

ok 200002 tokens

Test #19:

score: 0
Accepted
time: 649ms
memory: 69128kb

input:

6 525237 300000
add 2 290002 70001
add 2 212674 31337
add 1 288131 300001
add 1 174523 300001
add 2 200710 25355
add 1 252913 300001
add 1 249873 300001
add 2 233856 41928
add 2 173310 11655
add 1 259949 300001
add 2 161652 5826
add 2 294480 72240
add 1 277919 300001
add 2 248578 49289
add 1 274659 ...

output:

stdout ducks
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1...

result:

ok 150002 tokens

Test #20:

score: 0
Accepted
time: 241ms
memory: 69072kb

input:

12 474137 300000
add 1 289697 300001
add 1 270033 300001
add 2 151704 300001
add 1 227843 300001
add 2 258908 300001
add 1 258257 300001
add 1 278195 300001
add 2 177178 300001
add 1 262031 300001
add 2 257994 300001
add 2 246012 300001
add 1 156255 300001
add 1 154199 300001
add 2 274086 300001
add...

output:

stdout ducks
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1
150000 1...

result:

ok 150002 tokens

Test #21:

score: 0
Accepted
time: 628ms
memory: 109740kb

input:

3 507437 300000
add 2 263468 1
add 2 18764 1
add 2 234784 1
add 2 51694 1
add 1 138337 1
add 2 277350 1
add 2 164278 1
add 2 273256 1
add 1 228159 1
add 1 291167 1
add 2 229056 1
add 1 158651 1
add 1 23569 1
add 1 139583 1
add 2 174086 1
add 1 214003 1
add 2 103378 1
add 1 110929 1
add 2 15342 1
add...

output:

stdout ducks
299999 299999

result:

ok 4 tokens

Test #22:

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

input:

9999980 10000000 300000
add 425359 9662715 466
add 7659961 9908866 123
add 5503293 4784672 667
add 7973217 9002004 516
add 777273 3274888 160
add 5122548 8152428 453
add 2605317 3482320 20
add 5000253 9473947 150
add 439275 221799 645
add 5311647 4368638 574
add 4573989 2527895 695
add 3993944 97798...

output:

stdout ducks
299898
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1 1

result:

ok 104 tokens

Test #23:

score: 0
Accepted
time: 225ms
memory: 87536kb

input:

9999996 9999671 300000
add 5437539 5000001 3
add 8723106 5000001 2
add 4248070 5000001 2
add 2583477 5000001 1
add 2039758 5000001 1
add 7586898 5000001 2
add 3947839 5000001 3
add 3349885 5000001 3
add 5606654 5000001 1
add 1926048 5000001 1
add 584021 5000001 2
add 9630597 5000001 2
add 7407154 50...

output:

stdout ducks
0 0
0 0
1 0
0 0
1 0
0 0
0 0
1 0
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
0 0
0 0
0 0
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
1 1
1 0
1 0
0 0
1 0
1 0
0 0
0 0
1 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 0
1 1
1 1
1 0
0 0
1 0
0 0
1 0
1 0
1 0
0 0
1 0
1 0
0 0
1 0
1 0
1 1
1 1
1 1
1 0...

result:

ok 300001 tokens

Test #24:

score: 0
Accepted
time: 320ms
memory: 77092kb

input:

9999957 9999997 300000
add 8488259 8488259 1
add 2503660 2503660 3
add 8373131 8373131 3
add 7388164 7388164 2
add 2973914 2973914 3
add 1847337 1847337 1
add 1747929 1747929 1
add 5320208 5320208 3
add 8854376 8854376 3
add 324066 324066 2
add 7647769 7647769 2
add 4546618 4546618 3
add 9786419 978...

output:

stdout ducks
1 1
1 0
2 1
0 0
0 0
1 1
1 1
0 0
1 0
0 0
2 0
0 0
2 1
0 0
1 0
0 0
0 0
1 0
2 1
0 0
0 0
0 0
2 1
2 1
0 0
0 0
2 1
0 0
1 0
2 1
0 0
1 1
1 0
2 1
0 0
0 0
0 0
0 0
1 0
1 0
0 0
0 0
1 1
2 1
2 1
0 0
0 0
1 1
0 0
2 0
1 0
0 0
0 0
0 0
1 0
0 0
2 2
0 0
0 0
1 1
0 0
0 0
0 0
1 0
0 0
0 0
1 1
1 0
1 1
1 1
0 0
1 0...

result:

ok 300001 tokens

Test #25:

score: 0
Accepted
time: 326ms
memory: 78236kb

input:

9999830 9999960 300000
add 8264482 1735519 1
add 8816573 1183428 2
add 3544486 6455515 3
add 9412701 587300 2
add 3858509 6141492 3
add 3726458 6273543 1
add 6667638 3332363 3
add 9340441 659560 2
add 8314480 1685521 2
add 4373237 5626764 3
add 9215360 784641 2
add 2971134 7028867 2
add 5065055 4934...

output:

stdout ducks
1 0
0 0
1 0
1 1
2 1
0 0
1 0
0 0
2 1
0 0
1 0
0 0
1 1
0 0
0 0
1 0
2 1
0 0
1 0
0 0
0 0
0 0
1 0
1 1
0 0
0 0
1 1
2 0
0 0
0 0
1 1
0 0
2 1
1 0
0 0
0 0
0 0
2 1
2 0
2 0
2 1
2 1
2 1
2 0
2 1
1 1
1 0
2 1
1 0
2 0
2 1
0 0
0 0
0 0
0 0
0 0
0 0
1 1
0 0
0 0
1 0
0 0
0 0
0 0
0 0
2 1
1 0
1 0
1 0
0 0
0 0
0 0...

result:

ok 300001 tokens