QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#175721 | #6880. Operation Hope | Nyans | WA | 4536ms | 210100kb | C++14 | 1.9kb | 2023-09-10 21:57:43 | 2023-09-10 21:57:43 |
Judging History
answer
#include <cstdio>
#include <vector>
#include <algorithm>
int T, n, a[3][200010], id[3][200010];
std::vector <int> e[1600010];
int dfn[1600010], low[1600010], tm, Tm, stk[1600010], tp, col[1600010], cnt;
void tarjan(int u) {
dfn[u] = low[u] = ++tm, stk[++tp] = u;
for (int v: e[u]) {
if (dfn[v]) dfn[v] > Tm && low[u] > dfn[v]? low[u] = dfn[v]: 0;
else tarjan(v), low[u] > low[v]? low[u] = low[v]: 0;
}
if (low[u] == dfn[u])
for (++cnt, stk[tp + 1] = -1; stk[tp + 1] != u; --tp) col[stk[tp]] = cnt;
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n); n *= 2;
for (int i = 0; i < n; ++i) for (int k = 0; k < 3; ++k) scanf("%d", &a[k][i]);
for (int i = 0; i < n * 7; ++i) e[i].clear();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < n; ++j) id[i][j] = j;
std::sort(id[i], id[i] + n, [i](int x, int y) { return a[i][x] < a[i][y]; });
int L = (i * 2 + 1) * n, R = L + n;
for (int j = L + 1; j < R; ++j) e[j].push_back(j - 1), e[j + n - 1].push_back(j + n);
for (int j = 0; j < n; ++j) e[L + j].push_back(id[i][j] ^ 1), e[R + j].push_back(id[i][j] ^ 1);
}
int L = 0, R = 1e9;
while (L <= R) {
int mid = (L + R) / 2;
for (int i = 0; i < n; ++i) e[i].clear();
for (int i = 0; i < 3; ++i) {
int L = (i * 2 + 1) * n, R = L + n;
for (int k = 0, r = 0; k < n; ++k) {
int j = id[i][k];
while (a[i][id[i][r]] + mid < a[i][j]) ++r;
if (r) e[j].push_back(L + r - 1);
}
for (int k = n - 1, l = n - 1; k >= 0; --k) {
int j = id[i][k];
while (a[i][j] + mid < a[i][id[i][l]]) --l;
if (l != n - 1) e[j].push_back(R + l + 1);
}
}
for (int i = 0; i < n * 7; ++i) dfn[i] = 0; tm = 0;
for (int i = 0; i < n; ++i) if (!dfn[i]) Tm = tm, tarjan(i);
int F = 1;
for (int i = 0; i < n; i += 2) if (col[i] == col[i + 1]) F = 0;
if (F) R = mid - 1;
else L = mid + 1;
}
printf("%d\n", L);
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 4536ms
memory: 210100kb
input:
99 1000 532114032 55099632 197592060 601440117 964448551 693620489 68503446 149314803 308777541 408078601 977772348 978400861 185066959 236214410 460480442 842502015 709303988 675932475 793016330 161748857 511444978 852914351 281720292 552030608 9982160 15933748 8254470 175080600 567563770 461489051...
output:
983666938 499804923 99919477 99936031 99922111 99914205 99946480 99849310 66905080 981794820 499447574 99965775 99922055 99959755 99858165 99900104 99981039 36921268 983543586 499348157 99948914 99856361 99896238 99927070 99827404 99854234 48238983 986837467 499383664 99973920 99740185 99828429 9982...
result:
wrong answer 1st lines differ - expected: '982758431', found: '983666938'