QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#262965#1833. DeletingwsyearWA 1ms9864kbC++141.6kb2023-11-24 13:39:052023-11-24 13:39:06

Judging History

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

  • [2023-11-24 13:39:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9864kb
  • [2023-11-24 13:39:05]
  • 提交

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) 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: 0ms
memory: 7792kb

input:

2
1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7728kb

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: 1ms
memory: 7820kb

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: -100
Wrong Answer
time: 0ms
memory: 9864kb

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:

14

result:

wrong answer 1st numbers differ - expected: '30', found: '14'