社区讨论

95分求Hack

P6123[NEERC 2016] Hard Refactoring参与者 1已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@mlj7ang1
此快照首次捕获于
2026/02/12 16:32
上周
此快照最后确认于
2026/02/14 22:30
5 天前
查看原帖
难受。。。
CPP
#include <bits/stdc++.h>
using namespace std;
const int R = (1 << 16) + 1, D = 1 << 15;
int st[R], cnt;
string str, t;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	while (getline(cin, str)) {
		int x, y; 
		stringstream ss(str);
		if (str.find('&') != string::npos) {
			ss >> t >> t >> x >> t >> t >> t >> y;
			if (x <= y) st[x + D]++, st[y + D + 1]--;
		} else {
			ss >> t >> t >> x;
			if (str.find('<') != string::npos) st[0]++, st[x + D + 1]--;
			else st[x + D]++, st[2 * D]--;
		} cnt++;
	} int sum = st[0];
	for (int i = 1; i < R; i++) st[i] += st[i - 1], sum += (bool)(st[i]);
	if (sum == 2 * D || !cnt) return cout << "true", 0;
	if (sum == 0) return cout << "false", 0;
	for (int i = 0, lst = 0, fg = 0, mk = 0; i < R; i++)
		if (st[i] == 0) {
			if (fg) {
				if (mk) printf(" ||\n");
				if (i == R - 1) printf("x >= %d", lst - D);
				else if (!lst) printf("x <= %d", i - D - 1);
				else printf("x >= %d && x <= %d", lst - D, i - D - 1);
				mk = 1;
			} fg = 0;
		} else if (!fg) fg = 1, lst = i;
	return 0;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...