QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#111906#6335. Belt ConveyorScintilla1 425ms32112kbC++171.8kb2023-06-09 09:11:392023-06-09 09:11:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-09 09:11:41]
  • 评测
  • 测评结果:1
  • 用时:425ms
  • 内存:32112kb
  • [2023-06-09 09:11:39]
  • 提交

answer

#include "conveyor.h"

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#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>;
using vi = vector <int>;

void Solve(int n, vi x, vi y) {
  vi deg(n), p(n), id(n), dep(n), ans(n - 1, -1);
  vector <vector <pii>> e(n);
  rep(i, 0, n - 2) {
    ++ deg[x[i]], ++ deg[y[i]];
    e[x[i]].emplace_back(mp(y[i], i));
    e[y[i]].emplace_back(mp(x[i], i));
  }
  function <void(int)> dfs = [&](int u) {
    for (auto [v, i] : e[u]) if (v != p[u]) {
      p[v] = u, id[v] = i, dep[v] = dep[u] + 1, dfs(v);
    }
  } ;
  p[0] = -1, dfs(0);
  while (count(deg.begin(), deg.end(), 0) < n) {
    vi cnt(3), rev(n - 1), a(n);
    rep(u, 0, n - 1) cnt[dep[u] % 3] += deg[u] > 0;
    int r = max_element(cnt.begin(), cnt.end()) - cnt.begin();
    rep(u, 0, n - 1) if (deg[u]) a[u] = dep[u] % 3 == r;
    rep(u, 1, n - 1) if (~ans[id[u]]) {
      if (dep[p[u]] % 3 == r) rev[id[u]] = x[id[u]] == p[u];
      if (dep[u] % 3 == r) rev[id[u]] = x[id[u]] == u;
    }
    vi res = Query(rev, a);
    auto upd = [&](int i, int d) {
      if (!~ans[i]) -- deg[x[i]], -- deg[y[i]];
      ans[i] = d;
    } ;
    rep(u, 0, n - 1) if (deg[u] && dep[u] % 3 == r) {
      if (res[u]) {
        for (auto [v, i] : e[u]) upd(i, (x[i] == u) ^ rev[i]);
      }
      else {
        int w = -1, j = -1;
        for (auto [v, i] : e[u]) if (res[v]) {
          if (!~w || w == p[u]) w = v, j = i;
        }
        upd(j, (x[j] == w) ^ rev[j]);
      }
    }
  }
  Answer(ans);
}

詳細信息

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 2ms
memory: 3596kb

input:

random1
2
0
1
1
0xC321A02965AC2640

output:

Accepted: 1

result:

ok correct

Test #2:

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

input:

random1
2
1
0
0
0x8A99AD9552B2C218

output:

Accepted: 1

result:

ok correct

Test #3:

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

input:

random1
2
1
0
1
0x024D21FA307D148D

output:

Accepted: 1

result:

ok correct

Test #4:

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

input:

random1
2
0
1
0
0x3C96AB23CEB63F75

output:

Accepted: 1

result:

ok correct

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #5:

score: 0
Wrong Answer
time: 1ms
memory: 3676kb

input:

priority
30
10 29 10 13 17 11 2 15 15 27 9 26 18 0 14 1 22 24 29 28 6 22 4 20 15 5 28 4 21
24 3 13 1 8 13 12 8 19 16 3 1 10 24 29 12 8 4 7 2 7 28 25 12 7 2 23 27 22
89058848 6377689 24189123 31671827 205117644 254374430 56016068 6819602 212866321 246625321 274047319 230485311 202854776 280075001 203...

output:

Wrong Answer [5]

result:

wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 425ms
memory: 32112kb

input:

random1
100000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...

output:

Wrong Answer [5]

result:

wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%