QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#262970 | #1833. Deleting | wsyear | WA | 1ms | 9792kb | C++14 | 1.7kb | 2023-11-24 13:41:34 | 2023-11-24 13:41:34 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ " = "), debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using namespace std;
const int maxn = 4010;
const int maxm = 16000010;
int n, tot, cost[maxn][maxn];
bitset<maxn> f[maxn], vis[maxn], all;
pii p[maxm];
void tag(int l, int r) {
if (f[l].test(r)) return;
vis[l].set(r);
if (r == l + 1 || f[l + 1].test(r - 1)) f[l].set(r), f[r].set(l);
if (l > 1 && r < n && vis[l - 1].test(r + 1)) tag(l - 1, r + 1);
bitset<maxn> A = (all ^ f[l]) & f[r + 1];
for (int x = A._Find_next(r); x != maxn; x = A._Find_next(x)) tag(l, x);
bitset<maxn> B = (all ^ f[r]) & f[l - 1];
for (int x = B._Find_next(0); x < l; x = B._Find_next(x)) tag(x, r);
}
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n, all.set();
rep (i, 1, n) for (int j = i + 1; j <= n; j += 2) cin >> cost[i][j];
rep (i, 1, n) for (int j = i + 1; j <= n; j += 2) p[++tot] = pii(i, j);
sort(p + 1, p + tot + 1, [&](pii x, pii y) { return cost[x.fi][x.se] < cost[y.fi][y.se]; });
rep (i, 1, tot) {
tag(p[i].fi, p[i].se);
if (f[1].test(n)) return cout << cost[p[i].fi][p[i].se] << '\n', 0;
}
assert(0);
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7720kb
input:
2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7668kb
input:
6 2 1 3 4 5 6 7 8 9
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 9792kb
input:
10 20 21 2 11 25 3 24 18 8 6 17 7 5 22 4 23 14 15 1 19 16 12 10 13 9
output:
14
result:
ok 1 number(s): "14"
Test #4:
score: 0
Accepted
time: 0ms
memory: 7680kb
input:
16 49 48 18 41 52 64 4 6 22 20 32 50 56 36 9 3 1 27 58 51 35 40 61 43 38 12 7 34 8 59 39 25 46 16 44 29 15 17 24 10 47 2 57 62 14 5 23 33 30 45 19 60 63 28 13 54 55 26 53 31 11 42 21 37
output:
30
result:
ok 1 number(s): "30"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 7708kb
input:
20 91 19 90 92 5 41 15 50 18 36 97 8 23 74 53 67 83 40 26 4 16 31 82 80 28 49 6 21 58 63 70 34 27 89 68 20 55 100 35 77 52 24 11 87 94 13 66 1 32 54 86 60 79 75 93 45 73 2 48 72 12 37 29 95 56 17 44 84 30 22 14 65 76 69 62 47 78 7 57 42 39 61 99 81 88 25 98 59 85 38 10 33 51 71 64 46 43 3 96 9
output:
60
result:
wrong answer 1st numbers differ - expected: '54', found: '60'