QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626618 | #7617. Spectacle | isaunoya | WA | 0ms | 3592kb | C++23 | 2.8kb | 2024-10-10 10:51:32 | 2024-10-10 10:51:33 |
Judging History
answer
#if defined(local)
#include "./noya/debug.hpp"
#else
#define debug(...) 42
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define rep1(a) for (int i = 0; i < a; i++)
#define rep2(i, a) for (int i = 0; i < a; i++)
#define rep3(i, a, b) for (int i = a; i < b; i++)
#define rep4(i, a, b, c) for (int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define pb emplace_back
template <typename T, typename T2> void cmin(T &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T, typename T2> void cmax(T &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = int64_t;
using vi = vector<int>;
using vl = vector<ll>;
using ull = uint64_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> using vc = vector<T>;
const int INF = 1000000000;
const ll LNF = 1000000000000000000;
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
namespace noya {}
struct simple_dsu {
int N;
vector<int> par;
simple_dsu(int n) {
N = n;
par.resize(N);
iota(par.begin(), par.end(), 0);
}
int leader(int x) {
if (x == par[x])
return x;
return par[x] = leader(par[x]);
}
bool merge(int a, int b) {
if (leader(a) == leader(b))
return false;
par[leader(a)] = leader(b);
return true;
}
bool same(int a, int b) { return leader(a) == leader(b); }
};
int main() {
int N; cin >> N;
vi A(N);
for (auto &a : A)
cin >> a;
sort(A.begin(), A.end());
vc<array<int, 2>> P;
for (int i = 0; i + 1 < N; i++)
P.push_back({A[i + 1] - A[i], i});
sort(P.begin(), P.end());
simple_dsu f(N);
vector<int> siz(N, 1);
int cur = 0;
vector<int> ans(N, INF);
for (auto [val, i] : P) {
int A = siz[f.leader(i)];
int B = siz[f.leader(i + 1)];
cur -= A / 2;
cur -= B / 2;
f.merge(i, i + 1);
siz[f.leader(i)] = A + B;
cur += (A + B) / 2;
cmin(ans[cur], val);
}
for (int i = N / 2; i >= 1; i--)
cmin(ans[i - 1], ans[i]);
for (int i = 1; i <= N / 2; i++)
cout << ans[i] << " ";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3536kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6 '
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
2 1 1000000000000000000
output:
1000000000
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '1000000000 '