社区讨论
为什么过不了编译急急急
灌水区参与者 2已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @m5fbepfv
- 此快照首次捕获于
- 2025/01/02 20:41 去年
- 此快照最后确认于
- 2025/11/04 12:03 4 个月前
acwing 和本地的编译器都能跑,就是交上去编译失败,内容也没有说为什么失败,只有警告内容。
CPP#include <iostream>
#include <algorithm>
using namespace std;
const int N = 200010;
int dis[800010];
bool strA[N] = { 0 }, strB[N] = { 0 };
struct Chess {
int player, id, x, y;
bool operator< (const Chess& other) const {
if (x != other.x) return x < other.x;
return y < other.y;
}
} chess[N << 1];
int unique(int n) {
int las = -2e9, ret = 0;
for (int x = 1; x <= n; x++) {
if (las != dis[x])
dis[++ret] = dis[x];
las = dis[x];
}
return ret;
}
int get_ind(int n, int val) {
int l = 1, r = n, mid;
while (l < r) {
mid = l + r >> 1;
if (dis[mid] >= val) r = mid;
else l = mid + 1;
}
return r;
}
struct LasPlayer {
int p = -1, id = 0;
} laspX[N << 2], laspY[N << 2];
inline int read() {
int ret = 0, sym = 1;
char ch = getchar();
while (ch < '0' || '9' < ch) {
if (ch == '-') sym = -1;
ch = getchar();
}
while ('0' <= ch && ch <= '9')
ret = ret * 10 + ch - '0', ch = getchar();
return ret * sym;
}
int main() {
int n, m, k;
n = read(), m = read();
k = 0;
for (int x = 1; x <= n; x++) {
int x1 = read(), y1 = read();
chess[x] = { 0, x, x1, y1 };
dis[++k] = x1, dis[++k] = y1;
}
for (int x = 1; x <= m; x++) {
int x1 = read(), y1 = read();
chess[n + x] = { 1, x, x1, y1 };
dis[++k] = x1, dis[++k] = y1;
}
sort(dis + 1, dis + 1 + k);
k = unique(k);
for (int x = 1; x <= n + m; x++)
chess[x].x = get_ind(k, chess[x].x), chess[x].y = get_ind(k, chess[x].y);
sort(chess + 1, chess + 1 + n + m);
for (int i = 1; i <= n + m; i++) {
int x = chess[i].x, y = chess[i].y, p = chess[i].player;
int id = chess[i].id;
if (laspX[x].p != -1 && laspX[x].p != p) {
if (p) strA[laspX[x].id] = true, strB[id] = true;
else strB[laspX[x].id] = true, strA[id] = true;
}
laspX[x].p = p, laspX[x].id = id;
if (laspY[y].p != -1 && laspY[y].p != p) {
if (p) strA[laspY[y].id] = true, strB[id] = true;
else strB[laspY[y].id] = true, strA[id] = true;
}
laspY[y].p = p, laspY[y].id = id;
}
for (int i = 1; i <= n; i++) putchar(strA[i] + '0');
puts("");
for (int i = 1; i <= m; i++) putchar(strB[i] + '0');
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...