QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#724527 | #9574. Strips | ucup-team1338# | WA | 38ms | 5912kb | C++14 | 2.3kb | 2024-11-08 13:33:08 | 2024-11-08 13:33:09 |
Judging History
answer
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 1000006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
//#define int __int128
typedef long long ll;
const int P = 1e9 + 7;
int n , m , k , w;
int A[MAXN] , B[MAXN];
void solve() {
cin >> n >> m >> k >> w;
rep( i , 1 , n ) scanf("%d",A + i);
rep( i , 1 , m ) scanf("%d",B + i);
sort( A + 1 , A + 1 + n ) , sort( B + 1 , B + 1 + m );
B[0] = 0 , B[m + 1] = w + 1;
int l = 1 , r = 0;
vector<pii> ans;
int flg = 0;
rep( i , 0 , m ) {
while( l <= n && A[l] < B[i] ) ++ l;
while( r <= n && A[r + 1] < B[i + 1] ) ++ r;
if( l > r ) continue;
int sr = l;
int j = l;
vector<pair<int,int>> vec;
while( j <= r ) {
while (sr <= r && A[sr] < A[j] + k) ++sr;
vec.eb( A[j] , A[j] + k - 1 );
j = sr;
}
int R = B[i + 1];
while( vec.size() && vec.back().se >= R ) {
int dir = vec.back().se - R + 1;
ans.eb( vec.back().fi - dir , vec.back().se - dir );
R = vec.back().fi - dir;
vec.pop_back();
}
// cout << "Black " << B[i] << ' ' << B[i + 1] << endl;
// for( auto t : ans ) cout << t.fi << ' ' << t.se << endl;
if( vec.size() ) {
for( auto p : vec ) ans.eb( p );
} else {
if( ans.back().fi <= B[i] ) {
flg = 1; break;
}
}
// cout << "Current " << endl;
// for( auto t : ans ) cout << t.fi << ' ' << t.se << endl;
}
if( flg ) puts("-1");
else {
printf("%d\n",(int)ans.size());
for( auto t : ans ) printf("%d ",t.fi); puts("");
}
}
signed main() {
int T;cin >> T;while( T-- ) solve();
// solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5848kb
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 10 7 14 -1 2 1 5 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 38ms
memory: 5912kb
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:
4 3 32 0 0 8 3 4 14 22 28 36 40 0 3 32 48 66 8 3 9 22 26 31 38 54 65 3 5 15 30 6 1 8 12 31 47 41 4 17 39 30 49 6 52 67 30 30 30 30 1 27 -1 3 62 23 23 7 24 33 43 64 48 60 65 4 4 31 43 43 -1 3 3 16 33 4 25 30 42 43 3 3 17 60 4 21 11 1 33 3 54 66 9 3 50 59 65 4 50 62 78 0 1 81 4 2 1...
result:
wrong answer Integer parameter [name=c] equals to 4, violates the range [-1, 3] (test case 1)