QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86033#5689. 喵了个喵 IIScintillaWA 391ms174716kbC++143.0kb2023-03-09 08:26:252023-03-09 08:26:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-09 08:26:50]
  • 评测
  • 测评结果:WA
  • 用时:391ms
  • 内存:174716kb
  • [2023-03-09 08:26:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb emplace_back
#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define drep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << ' '; cout << endl

using pii = pair <int, int>;

const int N = 2e6 + 10;

int read() {
  int x = 0, f = 1; char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x * f;
}

int n, m, p[N][4], cur[N], ans[N], cnt, tot, val[N];
vector <int> e[N];

struct node {
  int x, y, id, o;
  node(int _x = 0, int _y = 0, int _id = 0, int _o = 0) {
    x = _x, y = _y, id = _id, o = _o;
  }
  friend bool operator < (node a, node b) {
    return a.x == b.x ? a.y < b.y : a.x < b.x;
  }
} dat[N];

void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  auto id = [&](int i, int o) { return n * o + i; } ;
  sort(dat + l, dat + r + 1);
  // cout << "----- l, r = " << l << ' ' << r << endl;
  sort(dat + l, dat + mid + 1, [&](node a, node b) { return a.y < b.y; });
  sort(dat + mid + 1, dat + r + 1, [&](node a, node b) { return a.y < b.y; });
  // rep(i, l, r) cout << dat[i].x << ' ' << dat[i].y << endl;
  rep(i, l, mid) e[m + i - l + 1].pb(id(dat[i].id, !dat[i].o));
  rep(i, l + 1, mid) e[m + i - l].pb(m + i - l + 1);
  for (int i = l, j = mid + 1; i <= mid && j <= r; ++ i) {
    while (i <= mid && dat[i].y <= dat[j].y) ++ i;
    if (i > mid) break;
    // cout << "i, j = " << i << ' ' << j << endl;
    e[id(dat[j].id, dat[j].o)].pb(m + i - l + 1);
  }
  m += mid - l + 1;
  // pv(m);
  cdq(l, mid), cdq(mid + 1, r);
}

int dfn[N], dn, low[N], top, st[N], col[N], cn;
void tarjan(int u) {
  dfn[u] = low[u] = ++ dn, st[++ top] = u;
  for (int v : e[u]) {
    if (!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]);
    else if (!col[v]) low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    for (++ cn; st[top + 1] != u; -- top) col[st[top]] = cn;
  }
}

int main() {
  n = read(), m = 2 * n;
  for (int i = 1, x; i <= n << 2; ++ i) x = read(), p[x][cur[x] ++] = i;
  rep(i, 1, n) {
    dat[++ cnt] = node(p[i][0], p[i][1], i, 0);
    dat[++ cnt] = node(p[i][2], p[i][3], i, 0);
    dat[++ cnt] = node(p[i][0], p[i][2], i, 1);
    dat[++ cnt] = node(p[i][1], p[i][3], i, 1);
  }
  // rep(i, 1, cnt) cout << dat[i].x << ' ' << dat[i].y << endl;
  cdq(1, cnt);
  // pv(m);
  // rep(u, 1, m) {
    // for (int v : e[u]) cout << u << ' ' << v << endl;
  // }
  rep(i, 1, m) if (!dfn[i]) tarjan(i);
  // pa(col, 1, 2 * n);
  rep(i, 1, n) if (col[i] == col[n + i]) return printf("No\n"), 0;
  printf("Yes\n");
  rep(i, 1, n) ans[p[i][0]] = ans[p[i][2 - (col[i] > col[n + i])]] = 1;
  // rep(i, 1, n << 2) printf("%d", ans[i]);
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 391ms
memory: 174716kb

input:

50000
12725 41478 2443 1096 36968 36898 3393 45898 43154 26629 22985 37972 13935 25628 40196 40293 39791 29109 455 45812 12634 21086 8928 13600 25416 30244 15917 22568 35849 40189 27442 28785 46334 25651 7172 30994 39724 27853 47091 21306 42087 31612 22081 23002 17127 15269 11569 8254 41080 30112 31...

output:

Yes

result:

wrong output format Unexpected end of file - token expected