QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#199103#6718. Масив i частковi сумиLeasier100 ✓100ms16768kbC++987.8kb2023-10-03 21:04:372023-10-03 21:04:37

Judging History

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

  • [2023-10-03 21:04:37]
  • 评测
  • 测评结果:100
  • 用时:100ms
  • 内存:16768kb
  • [2023-10-03 21:04:37]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;

typedef struct Item_tag {
	int pos;
	ll req;
	Item_tag(){}
	Item_tag(int pos_, ll req_){
		pos = pos_;
		req = req_;
	}
} Item;

typedef struct Segment_tag {
	int k;
	ll b;
	
	Segment_tag(){}
	
	Segment_tag(int k_, ll b_){
		k = k_;
		b = b_;
	}
	
	inline ll calc(int x){
		return (ll)k * x + b;
	}
} Segment;

typedef struct {
	int ls;
	int rs;
	Segment seg;
} Node;

int top, root, id;
int a[200007], sum[200007], min_val[200007], max_val[200007], stk[100007], p[200007];
ll sum_[200007], val[200007];
Item item[100007];
Node tree[800007];

bool operator <(const Item a, const Item b){
	return a.req > b.req;
}

inline void check0(int n){
	for (register int i = 1; i <= n; i++){
		if (a[i] < 0) return;
	}
	cout << 0 << endl;
	exit(0);
}

inline void check1_flip(int n){
	for (register int i = 1; i <= n; i++){
		if (a[i] > 0) return;
	}
	cout << 1 << endl;
	cout << 1 << endl;
	exit(0);
}

inline void check1_pre(int n){
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		if (sum[i] < 0) return;
	}
	cout << 1 << endl;
	cout << "2 1 " << n << endl;
	exit(0);
}

inline void check1_suf(int n){
	for (register int i = n; i >= 1; i--){
		sum[i] = sum[i + 1] + a[i];
		if (sum[i] < 0) return;
	}
	cout << 1 << endl;
	cout << "3 1 " << n << endl;
	exit(0);
}

inline void check2_flip_pre(int n){
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] - a[i];
		if (sum[i] < 0) return;
	}
	cout << 2 << endl;
	cout << 1 << endl;
	cout << "2 1 " << n << endl;
	exit(0);
}

inline void check2_flip_suf(int n){
	for (register int i = n; i >= 1; i--){
		sum[i] = sum[i + 1] - a[i];
		if (sum[i] < 0) return;
	}
	cout << 2 << endl;
	cout << 1 << endl;
	cout << "3 1 " << n << endl;
	exit(0);
}

inline void check2_pre_pre(int n){
	int pos = n, r = 0;
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		sum_[i] = sum_[i - 1] + sum[i];
	}
	for (register int i = 1; i <= n; i++){
		if (sum_[i] < 0){
			pos = i - 1;
			break;
		}
	}
	min_val[n + 1] = 1e9;
	for (register int i = n; i >= 1; i--){
		min_val[i] = min(min_val[i + 1], sum[i]);
	}
	for (register int i = 1; i <= pos; i++){
		if (sum_[i - 1] + min_val[i + 1] >= 0){
			r = i;
			break;
		}
	}
	if (r == 0) return;
	cout << 2 << endl;
	cout << "2 1 " << r << endl;
	cout << "2 1 " << n << endl;
	exit(0);
}

inline void check2_suf_suf(int n){
	int pos = 1, l = 0;
	for (register int i = n; i >= 1; i--){
		sum[i] = sum[i + 1] + a[i];
		sum_[i] = sum_[i + 1] + sum[i];
	}
	for (register int i = n; i >= 1; i--){
		if (sum_[i] < 0){
			pos = i + 1;
			break;
		}
	}
	min_val[0] = 1e9;
	for (register int i = 1; i <= n; i++){
		min_val[i] = min(min_val[i - 1], sum[i]);
	}
	for (register int i = pos; i <= n; i++){
		if (sum_[i + 1] + min_val[i - 1] >= 0){
			l = i;
			break;
		}
	}
	if (l == 0) return;
	cout << 2 << endl;
	cout << "3 " << l << " " << n << endl;
	cout << "3 1 " << n << endl;
	exit(0);
}

inline void check2_minmax(int n){
	int min_pos = 0, max_pos = 0;
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		if (min_pos == 0 || sum[min_pos] > sum[i]) min_pos = i;
		if (max_pos == 0 || sum[max_pos] < sum[i]) max_pos = i;
	}
	if (min_pos == n || min_pos > max_pos) return;
	cout << 2 << endl;
	cout << "2 " << min_pos + 1 << " " << n << endl;
	cout << "3 1 " << max_pos << endl;
	exit(0);
}

inline ll divide(ll x, int y){
	if (x >= 0) return x / y;
	return -((-x - 1) / y + 1);
}

inline ll query(int x, ll y){
	int l = 2, r = top;
	ll ans = divide(y - sum_[stk[1]], x - stk[1]);
	while (l <= r){
		int mid = (l + r) >> 1;
		if ((y - sum_[stk[mid]]) * (x - stk[mid - 1]) < (ll)(y - sum_[stk[mid - 1]]) * (x - stk[mid])){
			l = mid + 1;
			ans = divide(y - sum_[stk[mid]], x - stk[mid]);
		} else {
			r = mid - 1;
		}
	}
	return ans;
}

bool cmp(const int a, const int b){
	return sum[a - 1] > sum[b - 1];
}

void insert(int &x, int l, int r, Segment seg){
	int mid = (l + r) >> 1;
	if (x == 0){
		x = ++id;
		tree[x].ls = tree[x].rs = 0;
		tree[x].seg.k = 0x7fffffff;
	}
	if (tree[x].seg.k == 0x7fffffff || tree[x].seg.calc(mid) < seg.calc(mid)) swap(tree[x].seg, seg);
	if (l == r || seg.k == 0x7fffffff) return;
	if (tree[x].seg.calc(l) < seg.calc(l)) insert(tree[x].ls, l, mid, seg);
	if (tree[x].seg.calc(r) < seg.calc(r)) insert(tree[x].rs, mid + 1, r, seg);
}

ll get_max(int x, int l, int r, int k){
	if (x == 0) return 0x8000000000000000ll;
	int mid = (l + r) >> 1;
	ll ans = tree[x].seg.calc(k);
	if (l < r){
		if (k <= mid){
			ans = max(ans, get_max(tree[x].ls, l, mid, k));
		} else {
			ans = max(ans, get_max(tree[x].rs, mid + 1, r, k));
		}
	}
	return ans;
}

bool divide(int l, int r, int n, int minr, int &ansl, int &ansr){
	if (l == r || minr > r) return false;
	int mid = (l + r) >> 1, cnt = 0;
	top = 0;
	for (register int i = mid + 1; i <= r; i++){
		while (top > 1 && (sum_[i - 1] - sum_[stk[top]]) * (stk[top] - stk[top - 1]) >= (sum_[stk[top]] - sum_[stk[top - 1]]) * ((i - 1) - stk[top])) top--;
		stk[++top] = i - 1;
		if (i >= minr) item[++cnt] = Item(i, query(i, sum_[i - 1] + sum[n]));
	}
	sort(item + 1, item + cnt + 1);
	for (register int i = l; i <= mid; i++){
		p[i] = i;
	}
	sort(p + l, p + mid + 1, cmp);
	root = id = 0;
	for (register int i = mid; i >= l; i--){
		insert(root, -n, n, Segment(-(i - 1), sum_[i - 1] - sum[n]));
		val[i] = get_max(root, -n, n, sum[i - 1]);
	}
	root = id = 0;
	for (register int i = l, j = 1; i <= mid; i++){
		ll down = max(val[p[i]], sum_[p[i] - 1] + max_val[p[i] - 1] - sum[n] - (ll)p[i] * sum[p[i] - 1]);
		while (j <= cnt && item[j].req >= sum[p[i] - 1]){
			insert(root, -n, n, Segment(-item[j].pos, sum_[item[j].pos - 1]));
			j++;
		}
		if (down <= get_max(root, -n, n, sum[p[i] - 1])){
			ansl = p[i];
			for (register int k = 1; k < j; k++){
				if (down <= sum_[item[k].pos - 1] - (ll)item[k].pos * sum[p[i] - 1]){
					ansr = item[k].pos;
					break;
				}
			}
			return true;
		}
	}
	return divide(l, mid, n, minr, ansl, ansr) || divide(mid + 1, r, n, minr, ansl, ansr);
}

inline bool solve(int n, int &ansl, int &ansr){
	int minr = n;
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] + a[i];
		sum_[i] = sum_[i - 1] + sum[i];
		max_val[i] = max(max_val[i - 1], sum[i]);
	}
	while (sum[n] - sum[minr - 1] >= 0) minr--;
	return divide(1, n, n, minr, ansl, ansr);
}

inline void check2_pre_suf(int n){
	int l, r;
	if (solve(n, l, r)){
		cout << 2 << endl;
		cout << "2 " << l << " " << r << endl;
		cout << "3 1 " << n << endl;
		exit(0);
	}
}

inline void check2_suf_pre(int n){
	int l, r;
	reverse(a + 1, a + n + 1);
	if (solve(n, l, r)){
		cout << 2 << endl;
		cout << "3 " << n - r + 1 << " " << n - l + 1 << endl;
		cout << "2 1 " << n << endl;
		exit(0);
	}
	reverse(a + 1, a + n + 1);
}

inline void check3_flip_minmax(int n){
	int min_pos = 0, max_pos = 0;
	for (register int i = 1; i <= n; i++){
		sum[i] = sum[i - 1] - a[i];
		if (min_pos == 0 || sum[min_pos] > sum[i]) min_pos = i;
		if (max_pos == 0 || sum[max_pos] < sum[i]) max_pos = i;
	}
	if (min_pos == n || min_pos > max_pos) return;
	cout << 3 << endl;
	cout << 1 << endl;
	cout << "2 " << min_pos + 1 << " " << n << endl;
	cout << "3 1 " << max_pos << endl;
	exit(0);
}

int main(){
	int n, g;
	cin >> n >> g;
	for (register int i = 1; i <= n; i++){
		cin >> a[i];
	}
	check0(n);
	check1_flip(n);
	check1_pre(n);
	check1_suf(n);
	check2_flip_pre(n);
	check2_flip_suf(n);
	check2_pre_pre(n);
	check2_suf_suf(n);
	check2_minmax(n);
	check2_pre_suf(n);
	check2_suf_pre(n);
	check3_flip_minmax(n);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 14
Accepted

Test #1:

score: 14
Accepted
time: 14ms
memory: 4148kb

input:

200000 1
1 1 0 0 1 0 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 0...

output:

0

result:

ok OK: 0 operations

Test #2:

score: 0
Accepted
time: 16ms
memory: 6312kb

input:

200000 1
-1 0 0 0 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 0 0 0 -1 -1 0 -1 0 -1 0 -1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 0 0 0 -1 0 -1 -1 -1 0 -1 -1 0 0 0 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 0 -1 0 -1 -1 -1 0 -1 -1 0 0 0 0 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 -...

output:

1
1

result:

ok OK: 1 operations

Test #3:

score: 0
Accepted
time: 19ms
memory: 5840kb

input:

200000 1
0 0 1 -1 1 1 -1 -1 0 1 -1 0 0 1 0 0 1 1 1 1 0 -1 -1 0 -1 -1 1 -1 1 1 1 1 -1 1 -1 1 1 0 -1 -1 0 1 0 0 0 0 1 1 -1 0 0 -1 -1 -1 0 0 0 1 1 1 -1 1 1 0 0 1 1 -1 1 0 0 1 1 1 1 -1 0 1 0 0 0 0 1 0 0 -1 0 -1 1 -1 0 1 -1 -1 0 0 0 -1 0 0 1 1 1 0 -1 0 1 1 1 0 1 0 0 0 -1 -1 0 -1 -1 1 -1 -1 1 1 0 1 1 1 -1...

output:

1
2 1 200000

result:

ok OK: 1 operations

Test #4:

score: 0
Accepted
time: 19ms
memory: 5600kb

input:

200000 1
-1 -1 -1 -1 0 1 0 -1 -1 0 -1 -1 1 0 0 -1 0 1 -1 0 -1 1 -1 0 1 1 0 1 1 1 0 0 1 -1 0 1 0 0 0 0 1 1 1 1 1 0 1 -1 1 1 0 -1 0 1 0 0 0 1 1 0 1 0 -1 -1 0 0 -1 -1 0 1 -1 -1 -1 0 1 0 0 -1 0 1 0 1 1 1 1 0 1 -1 -1 -1 0 0 0 -1 1 1 -1 -1 -1 1 0 0 -1 -1 0 -1 -1 -1 0 1 1 1 1 0 1 -1 -1 0 -1 0 0 0 -1 -1 -1 ...

output:

1
3 1 200000

result:

ok OK: 1 operations

Subtask #2:

score: 17
Accepted

Test #5:

score: 17
Accepted
time: 17ms
memory: 4212kb

input:

200000 2
1 1 0 0 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #6:

score: 0
Accepted
time: 20ms
memory: 5760kb

input:

200000 2
0 0 -1 -1 0 -1 0 0 -1 -1 0 -1 -1 0 -1 0 -1 -1 -1 -1 -1 0 0 -1 0 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 -1 0 0 0 -1 -1 0 0 -1 -1 -1 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 0 0 -1 -1 -1 0 0 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 0 0 0 -1 -1...

output:

1
1

result:

ok OK: 1 operations

Test #7:

score: 0
Accepted
time: 85ms
memory: 14140kb

input:

200000 2
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
3 10031 52201
2 1 200000

result:

ok OK: 2 operations

Test #8:

score: 0
Accepted
time: 55ms
memory: 16336kb

input:

200000 2
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

2
2 167935 199997
3 1 200000

result:

ok OK: 2 operations

Test #9:

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

input:

200000 2
1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 1 0 0 -1 0 -1 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 ...

output:

3
1
2 14 200000
3 1 199995

result:

ok OK: 3 operations

Test #10:

score: 0
Accepted
time: 22ms
memory: 9120kb

input:

200000 2
-1 0 1 -1 0 1 1 0 1 0 0 1 0 1 -1 1 1 -1 1 -1 -1 0 -1 -1 0 -1 0 0 0 1 1 0 -1 1 -1 0 1 0 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 0 1 -1 0 -1 1 -1 0 -1 1 -1 0 1 1 1 0 -1 0 -1 -1 -1 -1 0 0 -1 1 -1 -1 0 1 -1 0 0 0 0 0 0 1 1 1 0 -1 0 -1 1 -1 1 -1 1 1 0 0 1 1 -1 1 1 -1 -1 1 0 -1 1 -1 0 0 0 -1 0 0 1 1 -1 ...

output:

2
3 192354 200000
3 1 200000

result:

ok OK: 2 operations

Subtask #3:

score: 18
Accepted

Dependency #2:

100%
Accepted

Test #11:

score: 18
Accepted
time: 14ms
memory: 5812kb

input:

200000 3
0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #12:

score: 0
Accepted
time: 21ms
memory: 4180kb

input:

200000 3
0 -1 0 -1 -1 -1 0 0 -1 0 -1 -1 0 0 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 -1 -1 0 0 -1 0 0 0 -1 -1 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 -1 0 -1 -1 0 0 0 -1 -1 -1 0 -1 -1 0 -1 0 -1 -1 -1 0 -1 0 -1 -1 0 -1 0 0 0 -1 -1 -1 -1 0 0 -1 -1 0 0 0 -1 0 0 -1 -1 0 0 -1 -1 0 0 0 0 0 -1 0 0 0 0 -1 -1 0 -1...

output:

1
1

result:

ok OK: 1 operations

Test #13:

score: 0
Accepted
time: 17ms
memory: 5004kb

input:

200000 3
-1 -1 -1 -1 1 -1 0 1 -1 0 -1 -1 -1 1 1 0 -1 0 1 -1 1 0 -1 0 0 1 -1 0 -1 0 0 -1 1 -1 1 1 -1 -1 0 -1 1 1 0 0 1 0 1 1 1 -1 0 -1 0 1 1 1 -1 -1 -1 1 -1 0 -1 0 1 -1 1 -1 -1 -1 1 0 1 1 -1 0 0 -1 1 -1 1 1 1 1 0 -1 1 -1 0 -1 -1 1 0 0 1 -1 1 -1 0 1 0 0 0 1 0 -1 -1 1 -1 -1 0 1 -1 1 1 0 0 1 0 1 0 1 1 -...

output:

1
3 1 200000

result:

ok OK: 1 operations

Test #14:

score: 0
Accepted
time: 21ms
memory: 9192kb

input:

193638 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1...

output:

2
2 1 625
2 1 193638

result:

ok OK: 2 operations

Test #15:

score: 0
Accepted
time: 90ms
memory: 16388kb

input:

200000 3
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
3 13464 70916
2 1 200000

result:

ok OK: 2 operations

Test #16:

score: 0
Accepted
time: 90ms
memory: 16768kb

input:

200000 3
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1...

output:

2
3 3 44502
2 1 200000

result:

ok OK: 2 operations

Test #17:

score: 0
Accepted
time: 44ms
memory: 12924kb

input:

200000 3
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

2
2 72290 168773
3 1 200000

result:

ok OK: 2 operations

Test #18:

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

input:

200000 3
1 1 1 0 0 0 0 0 0 0 -1 0 0 0 1 0 0 0 -1 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 -1 0 -1 0 -1 0 -1 0 0 0 -1 0 0 1 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 0 0 -1 0 0 0 0 0 -1 1 0 0 0 -1 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0...

output:

3
1
2 4 200000
3 1 199994

result:

ok OK: 3 operations

Test #19:

score: 0
Accepted
time: 22ms
memory: 9232kb

input:

200000 3
0 -1 1 1 0 0 0 1 -1 0 1 0 -1 -1 1 -1 -1 0 -1 -1 -1 0 0 1 0 0 0 -1 0 1 -1 -1 0 0 1 1 1 0 -1 1 1 0 -1 0 -1 0 1 0 1 0 0 -1 -1 -1 0 1 -1 0 1 -1 0 0 0 0 1 0 1 1 0 -1 0 1 0 1 1 -1 -1 -1 0 0 1 0 0 -1 0 -1 1 0 0 -1 1 1 1 0 0 0 1 -1 1 -1 0 -1 1 -1 1 0 -1 1 -1 0 1 -1 1 -1 0 0 0 0 -1 1 0 1 0 -1 -1 1 -...

output:

2
2 23840 200000
3 1 138764

result:

ok OK: 2 operations

Subtask #4:

score: 7
Accepted

Dependency #3:

100%
Accepted

Test #20:

score: 7
Accepted
time: 17ms
memory: 4384kb

input:

200000 4
1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 1 0 1 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #21:

score: 0
Accepted
time: 20ms
memory: 4220kb

input:

200000 4
-1 -1 -1 -1 0 0 -1 -1 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 -1 0 -1 -1 0 -1 -1 0 0 -1 0 -1 0 0 -1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 -1 0 -1 0 -1 0 0 -1 0 -1 -1 0 -1 -1 0 -1 ...

output:

1
1

result:

ok OK: 1 operations

Test #22:

score: 0
Accepted
time: 20ms
memory: 6228kb

input:

200000 4
-1 1 1 -1 1 -1 0 -1 -1 0 0 -1 0 1 1 1 1 -1 0 -1 -1 -1 -1 0 1 -1 -1 1 -1 0 1 1 0 1 1 0 0 0 0 1 -1 1 0 0 -1 -1 -1 1 1 1 1 0 1 1 0 0 0 0 1 -1 1 0 0 1 1 -1 -1 0 1 -1 1 1 0 1 0 1 1 0 1 -1 1 0 1 0 0 1 0 0 0 1 1 0 1 1 -1 -1 0 -1 0 1 0 -1 0 1 -1 1 1 0 -1 -1 0 0 0 -1 -1 1 1 0 1 0 0 0 -1 -1 -1 -1 0 1...

output:

1
3 1 200000

result:

ok OK: 1 operations

Test #23:

score: 0
Accepted
time: 21ms
memory: 7936kb

input:

192074 4
1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2
2 1 624
2 1 192074

result:

ok OK: 2 operations

Test #24:

score: 0
Accepted
time: 82ms
memory: 14608kb

input:

200000 4
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
3 11937 58982
2 1 200000

result:

ok OK: 2 operations

Test #25:

score: 0
Accepted
time: 59ms
memory: 15040kb

input:

200000 4
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

2
2 161939 188990
3 1 200000

result:

ok OK: 2 operations

Test #26:

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

input:

200000 4
1 1 1 1 1 1 1 1 1 1 -1 0 0 0 0 -1 0 -1 0 0 0 -1 0 1 -1 0 0 1 -1 0 0 0 0 -1 0 -1 -1 0 0 0 -1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0...

output:

3
1
2 11 200000
3 1 199987

result:

ok OK: 3 operations

Test #27:

score: 0
Accepted
time: 39ms
memory: 11972kb

input:

200000 4
0 -1 0 0 0 -1 1 1 1 0 1 1 1 -1 -1 -1 -1 -1 1 0 1 1 0 -1 0 -1 0 1 -1 0 -1 0 0 -1 1 1 -1 1 0 0 1 1 0 0 0 1 0 -1 0 -1 -1 -1 1 0 0 1 0 -1 1 1 1 1 1 0 -1 1 -1 1 1 1 0 -1 -1 0 1 1 1 1 0 0 0 0 -1 1 -1 1 0 1 -1 -1 0 1 1 -1 -1 0 0 -1 1 1 1 1 1 0 -1 0 -1 1 -1 1 0 0 1 0 -1 0 1 -1 1 0 1 1 -1 1 1 1 0 1 ...

output:

2
2 83073 200000
3 1 200000

result:

ok OK: 2 operations

Subtask #5:

score: 7
Accepted

Test #28:

score: 7
Accepted
time: 0ms
memory: 5508kb

input:

2891 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 ...

output:

2
2 1 75
2 1 2891

result:

ok OK: 2 operations

Test #29:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

2847 5
1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

2
2 1 80
2 1 2847

result:

ok OK: 2 operations

Test #30:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

2981 5
1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

2
2 1 80
2 1 2981

result:

ok OK: 2 operations

Test #31:

score: 0
Accepted
time: 1ms
memory: 5600kb

input:

3000 5
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
2 1 1456
2 1 3000

result:

ok OK: 2 operations

Test #32:

score: 0
Accepted
time: 1ms
memory: 5472kb

input:

3000 5
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
2 1 1463
2 1 3000

result:

ok OK: 2 operations

Subtask #6:

score: 19
Accepted

Dependency #5:

100%
Accepted

Test #33:

score: 19
Accepted
time: 21ms
memory: 9220kb

input:

191855 6
1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1...

output:

2
2 1 626
2 1 191855

result:

ok OK: 2 operations

Test #34:

score: 0
Accepted
time: 21ms
memory: 8144kb

input:

191982 6
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1...

output:

2
2 1 623
2 1 191982

result:

ok OK: 2 operations

Test #35:

score: 0
Accepted
time: 21ms
memory: 9440kb

input:

193538 6
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0...

output:

2
2 1 631
2 1 193538

result:

ok OK: 2 operations

Test #36:

score: 0
Accepted
time: 20ms
memory: 9304kb

input:

200000 6
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
2 1 96885
2 1 200000

result:

ok OK: 2 operations

Test #37:

score: 0
Accepted
time: 20ms
memory: 9460kb

input:

200000 6
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
2 1 96894
2 1 200000

result:

ok OK: 2 operations

Subtask #7:

score: 17
Accepted

Dependency #5:

100%
Accepted

Test #38:

score: 17
Accepted
time: 1ms
memory: 3568kb

input:

3000 7
1 0 1 0 1 1 0 0 0 0 0 1 0 1 1 1 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0...

output:

0

result:

ok OK: 0 operations

Test #39:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

3000 7
-1 0 0 1 1 0 0 0 -1 1 0 0 1 0 -1 0 0 1 -1 -1 -1 1 1 -1 1 1 0 -1 0 -1 -1 0 0 -1 -1 -1 0 0 1 1 -1 1 -1 -1 0 1 -1 -1 0 1 -1 -1 0 1 1 -1 1 1 1 -1 0 1 -1 0 -1 0 1 0 1 1 -1 1 -1 1 0 0 1 -1 0 1 1 0 -1 1 1 -1 1 0 1 0 0 -1 0 -1 0 1 1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 0 1 -1 -1 1 -1 -1 -1 -1 0 1 0 1 -1 0 -1...

output:

2
3 2060 3000
3 1 3000

result:

ok OK: 2 operations

Test #40:

score: 0
Accepted
time: 1ms
memory: 3460kb

input:

3000 7
-1 0 0 0 0 -1 0 -1 -1 0 0 0 0 0 -1 -1 0 -1 -1 0 0 0 0 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 -1 -1 0 0 -1 -1 -1 0 0 0 0 -1 0 -1 0 -1 0 -1 0 -1 0 0 -1 0 -1 0 0 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 0 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 -1 0 -1 -1 -1 -1 0 0 0 0 0 -1 0 0 -1 -1 -1 -1 0 ...

output:

1
1

result:

ok OK: 1 operations

Test #41:

score: 0
Accepted
time: 1ms
memory: 3436kb

input:

3000 7
-1 0 0 1 -1 1 -1 0 -1 1 -1 0 -1 1 1 1 0 1 -1 1 1 0 1 -1 -1 0 -1 1 0 0 -1 0 0 1 1 1 0 1 1 0 1 0 -1 0 0 -1 -1 1 1 0 0 1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 1 0 1 1 1 -1 1 0 0 0 -1 -1 0 0 1 0 1 -1 1 -1 0 1 -1 -1 0 -1 -1 0 1 0 0 -1 -1 0 -1 0 1 -1 1 -1 1 1 0 -1 1 0 0 -1 0 1 1 0 -1 1 1 1 0...

output:

1
3 1 3000

result:

ok OK: 1 operations

Test #42:

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

input:

3000 7
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 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 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

2
3 131 622
2 1 3000

result:

ok OK: 2 operations

Test #43:

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

input:

3000 7
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

2
2 2441 2830
3 1 3000

result:

ok OK: 2 operations

Test #44:

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

input:

3000 7
1 1 1 1 1 0 -1 -1 0 -1 -1 -1 0 0 0 -1 0 0 1 0 0 0 0 0 0 0 0 1 -1 -1 -1 0 0 0 -1 0 -1 -1 0 1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 0 0 0 0 0 -1 0 -1 0 0 -1 0 0 -1 -1 0 -1 -1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 ...

output:

3
1
2 6 3000
3 1 2995

result:

ok OK: 3 operations

Test #45:

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

input:

3000 7
1 1 1 -1 1 0 -1 0 0 -1 0 -1 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 0 0 0 0 -1 0 -1 0 0 0 1 0 -1 0 0 0 0 0 -1 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 -1 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 -1 -1 0 0 0 0 0 0 -1 -1 -1 0 0 0 -1 0 ...

output:

3
1
2 4 3000
3 1 2971

result:

ok OK: 3 operations

Test #46:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

2959 7
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1...

output:

2
3 2759 2959
3 1 2959

result:

ok OK: 2 operations

Test #47:

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

input:

3000 7
0 1 1 -1 -1 1 0 -1 -1 0 0 0 0 0 1 -1 0 -1 0 0 0 1 -1 1 -1 1 0 0 1 0 1 1 -1 1 -1 1 0 1 1 1 1 1 0 0 0 1 1 1 -1 -1 0 0 0 0 0 -1 -1 -1 -1 0 -1 1 0 -1 1 0 0 0 -1 1 -1 -1 0 1 0 1 -1 1 -1 1 1 -1 0 1 -1 0 0 1 0 -1 0 0 -1 -1 -1 0 0 1 -1 0 0 -1 1 -1 -1 -1 0 -1 0 -1 -1 0 -1 1 1 1 -1 1 0 -1 0 1 1 -1 1 0 ...

output:

2
2 2205 2999
3 1 3000

result:

ok OK: 2 operations

Subtask #8:

score: 1
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #48:

score: 1
Accepted
time: 21ms
memory: 5004kb

input:

200000 8
-1 -1 -1 0 -1 1 0 1 1 -1 0 0 0 0 0 -1 1 -1 1 -1 -1 0 1 0 -1 0 0 0 1 0 1 1 0 -1 -1 0 -1 1 1 -1 0 1 -1 0 0 -1 1 1 -1 0 1 -1 -1 -1 -1 1 0 1 -1 0 0 0 -1 -1 1 -1 1 0 -1 -1 -1 -1 -1 -1 0 1 0 -1 0 -1 -1 -1 -1 -1 1 1 -1 -1 0 0 1 1 -1 1 0 -1 -1 0 1 0 0 0 -1 1 -1 1 1 0 1 -1 -1 -1 -1 1 0 1 1 1 0 1 -1 ...

output:

2
1
2 1 200000

result:

ok OK: 2 operations

Test #49:

score: 0
Accepted
time: 19ms
memory: 9232kb

input:

193782 8
1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1...

output:

2
3 192137 193782
3 1 193782

result:

ok OK: 2 operations

Test #50:

score: 0
Accepted
time: 22ms
memory: 9296kb

input:

200000 8
1 -1 0 1 -1 0 -1 1 0 0 -1 0 0 0 1 0 -1 0 0 -1 -1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 -1 0 -1 0 1 1 0 0 -1 1 -1 -1 -1 0 -1 0 0 1 1 1 1 1 1 0 1 -1 1 1 0 -1 1 -1 0 0 0 0 0 0 -1 0 -1 1 -1 -1 0 -1 1 -1 0 1 0 -1 1 0 -1 -1 1 1 0 0 0 -1 -1 -1 1 0 -1 0 0 -1 0 1 -1 0 -1 -1 1 0 0 -1 1 1 0 1 -1 -1 1 -1 -1 1 ...

output:

2
2 248 200000
3 1 147643

result:

ok OK: 2 operations

Test #51:

score: 0
Accepted
time: 16ms
memory: 8212kb

input:

200000 8
0 -1 1 -1 0 0 0 -1 1 -1 1 -1 -1 1 1 0 0 1 1 0 -1 -1 1 1 1 1 -1 1 -1 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 1 1 1 -1 1 -1 -1 1 0 0 1 -1 0 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 0 1 0 -1 1 0 -1 1 0 0 1 0 -1 -1 0 0 -1 1 0 1 -1 1 -1 1 1 0 0 0 1 1 0 -1 -1 0 -1 -1 -1 -1 -1 -1 0 -1 1 1 -1 0 ...

output:

2
2 25014 200000
3 1 115742

result:

ok OK: 2 operations

Test #52:

score: 0
Accepted
time: 15ms
memory: 8392kb

input:

200000 8
1 1 0 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 0 -1 1 0 0 0 -1 1 0 0 0 -1 0 -1 0 -1 1 -1 1 0 0 0 -1 -1 0 1 -1 0 1 0 1 -1 -1 0 -1 0 1 1 1 -1 1 -1 0 -1 0 -1 1 1 1 1 0 1 0 -1 -1 0 1 -1 0 1 1 0 1 -1 -1 -1 0 1 1 -1 1 -1 0 1 0 -1 0 -1 -1 -1 1 0 -1 0 -1 1 0 0 -1 0 -1 -1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 0 -1 0 0 -1...

output:

2
2 3139 200000
3 1 103106

result:

ok OK: 2 operations

Test #53:

score: 0
Accepted
time: 21ms
memory: 4972kb

input:

200000 8
-1 0 -1 -1 0 1 0 1 0 0 0 -1 1 0 0 1 -1 1 -1 0 1 0 1 -1 1 1 -1 -1 0 0 1 -1 0 -1 0 1 -1 -1 -1 1 -1 1 0 0 1 -1 0 1 0 0 0 0 0 -1 0 1 0 1 1 0 -1 1 1 0 0 0 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 0 -1 -1 1 0 -1 0 0 1 -1 1 -1 0 0 -1 0 -1 0 -1 1 1 1 1 -1 1 -1 -1 1 1 1 -1 1 0 1 1 -1 -1 1 1 -1 1 -1 0 0 -1 0 1 1...

output:

2
1
3 1 200000

result:

ok OK: 2 operations

Test #54:

score: 0
Accepted
time: 93ms
memory: 14420kb

input:

200000 8
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
3 10546 43497
2 1 200000

result:

ok OK: 2 operations

Test #55:

score: 0
Accepted
time: 88ms
memory: 14456kb

input:

200000 8
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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2
3 22918 70162
2 1 200000

result:

ok OK: 2 operations

Test #56:

score: 0
Accepted
time: 33ms
memory: 13656kb

input:

200000 8
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

2
2 97777 175783
3 1 200000

result:

ok OK: 2 operations

Test #57:

score: 0
Accepted
time: 39ms
memory: 16440kb

input:

200000 8
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

2
2 139301 182131
3 1 200000

result:

ok OK: 2 operations

Test #58:

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

input:

200000 8
1 1 1 1 1 1 1 1 1 -1 0 -1 0 -1 -1 0 0 0 -1 0 -1 0 -1 -1 -1 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 0 -1 -1 0 1 0 -1 -1 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 -1 0 0 0 0 -1 0 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0...

output:

3
1
2 10 200000
3 1 199989

result:

ok OK: 3 operations

Test #59:

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

input:

200000 8
1 1 1 1 1 1 1 1 1 1 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 0 0 0 -1 0 0 -1 0 0 0 0 -1 0 1 0 0 1 -1 0 0 0 -1 0 0 0 0 0 -1 -1 0 -1 0 0 0 0 0 0 0 0 0 -1 -1 0 0 -1 0 0 0 1 0 -1 -1 0 -1 0 -1 0 0 0 0 0 0 1 0 0 0 -1 -1 0 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 ...

output:

3
1
2 11 200000
3 1 199985

result:

ok OK: 3 operations

Test #60:

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

input:

200000 8
1 1 1 1 1 1 1 1 -1 0 -1 -1 -1 -1 0 0 0 0 0 -1 0 0 0 -1 0 0 -1 -1 0 0 0 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 -1 -1 0 -1 0 1 0 0 0 0 0 0 1 0 0 0 0 -1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 -1 0 -1...

output:

3
1
2 9 200000
3 1 199983

result:

ok OK: 3 operations

Extra Test:

score: 0
Extra Test Passed