QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#119828 | #1156. Robots | somethingnew# | 0 | 0ms | 0kb | C++20 | 2.2kb | 2023-07-05 21:30:57 | 2024-07-04 00:19:20 |
Judging History
answer
// ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
// ➡ @roadfromroi ⬅
// ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;
#include "robots.h"
struct dsu {
vector<int> p;
vector<int> cnt;
void init(int n, int k) {
p.assign(n, {});
cnt.assign(n, k);
for (int i = 0; i < n; ++i) {
p[i] = i;
}
}
int getv(int v) {
if (v == p.size())
return v;
if (p[v] == v)
return v;
return p[v] = getv(p[v]);
}
bool op(int v) {
v = getv(v);
if (v == p.size())
return 0;
cnt[v]--;
if (cnt[v] == 0)
p[v] = v + 1;
return 1;
}
};
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<int> a;
vector<int> b;
for (int i = 0; i < A; ++i) {
a.push_back(W[i]);
}
for (int i = 0; i < B; ++i) {
b.push_back(S[i]);
}
sort(all(a));
sort(all(b));
vector<pair<int, int>> prpr;
for (int i = 0; i < T; ++i) {
X[i] = upper_bound(all(a), X[i]) - a.begin();
Y[i] = upper_bound(all(b), Y[i]) - b.begin();
prpr.push_back({X[i], Y[i]});
}
sort(all(prpr));
reverse(all(prpr));
int l = 0, r = T + 2;
while (l + 1 <= r) {
int m = l + r >> 1;
bool gd = 1;
dsu usdx, usdy;
usdx.init(a.size(), m);
usdy.init(b.size(), m);
for (auto [x, y] : prpr) {
if (usdy.op(y) == 0) {
if (usdx.op(x) == 0) {
gd = 0;
break;
}
}
}
if (gd) {
r = m;
} else {
l = m;
}
}
if (r > T) {
return -1;
}
return r;
}
/*
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin >> t;
}
*/
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1 1 2 13 13 5 6 13 13
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #8:
score: 0
Runtime Error
input:
50000 0 500000 1957680000 64280000 235160000 1384760000 1279320000 1005400000 1481760000 1129920000 1774640000 494160000 763120000 419640000 1742880000 1083000000 278360000 64040000 576880000 1479760000 1872320000 158480000 1183880000 81320000 249920000 30920000 1909240000 870920000 842280000 445640...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%