QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#728105 | #9574. Strips | ucup-team5234# | WA | 35ms | 3620kb | C++14 | 3.5kb | 2024-11-09 14:34:10 | 2024-11-09 14:34:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int) (x).size()
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(auto i = (a); i < (b); i++)
#define For(i, a, b, c) \
for(auto i = (a); i != (b); i += (c))
#define REPR(i, n) for(auto i = (n) - 1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), (v).end())
#define eb emplace_back
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
const double EPS = 1e-6;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const ll LINF = 1e18;
const double math_PI = acos(-1);
template<typename T>
vector<T> make_v(size_t a) {
return vector<T>(a);
}
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(
a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(
T &t, const V &v) {
t = v;
}
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(
T &t, const V &v) {
for(auto &e: t) fill_v(e, v);
}
template<class T>
bool chmax(T &a, const T &b) {
if(a < b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmin(T &a, const T &b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template<typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
cin >> p.first >> p.second;
return is;
}
template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
for(T &x: vec) is >> x;
return is;
}
template<typename T>
string join(vector<T> &vec, string splitter) {
stringstream ss;
REP(i, SZ(vec)) {
if(i != 0) ss << splitter;
ss << vec[i];
}
return ss.str();
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
os << join(vec, " ");
return os;
}
#ifdef LOCAL
#include "./cpp-dump/dump.hpp"
#include "./cpp-dump/mytypes.hpp"
#define dump(...) cpp_dump(__VA_ARGS__)
namespace cp = cpp_dump;
#else
#define dump(...)
#define preprocess(...)
#define CPP_DUMP_SET_OPTION(...)
#define CPP_DUMP_DEFINE_EXPORT_OBJECT(...)
#define CPP_DUMP_DEFINE_EXPORT_ENUM(...)
#define CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(...)
#endif
void solve() {
int N, M, K, W;
cin >> N >> M >> K >> W;
int preB = -1;
vi vR(N), vB(M);
cin >> vR >> vB;
so(vR);
so(vB);
queue<int> R, B;
REP(i, N) {
vR[i]--;
R.push(vR[i]);
}
REP(i, M) {
vB[i]--;
B.push(vB[i]);
}
B.push(W);
int right = -1;
vi ans;
while(!B.empty()) {
int len = B.front() - preB - 1;
int cnt = 0;
vi V;
while(!R.empty() && R.front() <= B.front()) {
int r = R.front();
if(r <= right && right - K + 1 > preB) {
R.pop();
continue;
}
right = r + K - 1;
cnt++;
V.push_back(r + 1);
if(cnt * K > len) {
cout << -1 << endl;
return;
}
R.pop();
}
REP(i, cnt) {
int v = V[i];
chmax(v, preB + 1 + i * K);
chmin(v, B.front() - K * (cnt - i));
ans.push_back(v + 1);
}
preB = B.front();
B.pop();
}
cout << SZ(ans) << endl;
cout << ans << endl;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int T;
cin >> T;
while(T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
4 5 2 3 16 7 11 2 9 14 13 5 3 2 4 11 6 10 2 1 11 2 1 2 6 1 5 3 2 1 2 6 1 5 2
output:
4 2 7 10 14 -1 2 1 5 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 35ms
memory: 3584kb
input:
11000 3 8 2 53 32 3 33 35 19 38 20 1 30 10 6 7 10 1 42 3 14 4 36 28 40 22 17 20 12 41 27 7 1 19 13 9 6 6 13 78 55 76 53 32 54 58 62 45 21 4 7 61 8 7 3 68 9 26 54 31 22 3 38 65 34 16 58 47 52 29 53 5 8 4 33 33 5 30 6 15 27 12 9 28 19 2 13 10 6 1 2 48 8 12 48 1 41 31 40 7 6 7 61 20 19 30 52 49 17 40 3...
output:
2 4 33 7 4 5 15 23 29 37 40 3 32 48 66 8 4 10 23 26 31 39 55 66 3 5 15 30 6 2 9 13 32 42 47 4 17 31 39 50 2 53 68 1 28 1 22 1 62 5 24 34 43 49 61 2 5 32 3 12 20 31 3 3 17 33 3 26 30 43 3 3 18 60 4 1 11 21 33 2 55 66 3 50 60 66 3 51 63 79 1 81 4 3 11 17 24 5 3 8 18 36 50 2 1 45 2 7 25 1 4 4 10 18 29 ...
result:
wrong answer There is no stripe covering red cell 3 (test case 1)