#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n, m1, m2, t;
int a[5010][2];
int dp[5010][2];
int main() {
fast;
cin >> n >> m1 >> m2 >> t;
for(int i=0; i<m1; i++) {
int x;
cin >> x;
a[x][0] = 1;
}
for(int i=0; i<m2; i++) {
int x;
cin >> x;
a[x][1] = 1;
}
dp[n+1][0] = dp[n+1][1] = n+1;
for(int i=n; i>=0; i--) {
dp[i][0] = max(dp[i][0], dp[i+1][0]);
if(!a[i+1][0]) dp[i][0] = max(dp[i][0], dp[i+1][0]);
if(!a[i+1][1]) dp[i][1] = max(dp[i][1], dp[i+1][1]);
if(!a[i][0] && !a[i+1][0]) dp[i][1] = max(dp[i][0], dp[i+1][0]);
if(!a[i][1] && !a[i+1][1]) dp[i][0] = max(dp[i][0], dp[i+1][0]);
}
if(dp[0][0] == n+1) {
cout << "Yes\n";
int y = 0;
vector<int> v;
for(int i=0; i<=n; i++) {
if(!a[i+1][y]) continue;
v.eb(i);
y = 1 - y;
}
cout << v.size() << "\n";
for(auto i : v) {
cout << i << " ";
}
cout << "\n";
cout << "0\n";
}
else {
cout << "No\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
[OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20 |
2 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000 |
3 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000 |
4 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000 |
5 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000 |
6 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000 |
7 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000 |
8 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000 |
9 |
Incorrect |
1 ms |
384 KB |
Tank was blowed at position (1, 3262) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
[OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20 |
2 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000 |
3 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000 |
4 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000 |
5 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000 |
6 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000 |
7 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000 |
8 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000 |
9 |
Incorrect |
1 ms |
384 KB |
Tank was blowed at position (1, 3262) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Tank was blowed at position (1, 5) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
[OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20 |
2 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000 |
3 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000 |
4 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000 |
5 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000 |
6 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000 |
7 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000 |
8 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000 |
9 |
Incorrect |
1 ms |
384 KB |
Tank was blowed at position (1, 3262) |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
[OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20 |
2 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000 |
3 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000 |
4 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000 |
5 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000 |
6 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000 |
7 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000 |
8 |
Correct |
1 ms |
384 KB |
[OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000 |
9 |
Incorrect |
1 ms |
384 KB |
Tank was blowed at position (1, 3262) |
10 |
Halted |
0 ms |
0 KB |
- |