QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300351 | #4825. Even and Odd Combinations | wxhtzdy | 0 | 0ms | 0kb | C++20 | 1.0kb | 2024-01-08 04:10:17 | 2024-01-08 04:10:18 |
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n, k;
cin >> n >> k;
vector<int> a(k);
for (int i = 0; i < k; i++) {
cin >> a[i];
--a[i];
}
vector<int> c(n);
for (int i = 0; i < k; i++) {
c[a[i]] = 1;
}
if (n % 2 == 1) {
vector<int> res;
for (int i = 0; i < n; i++) {
if (c[i] == 0) {
res.push_back(i);
}
}
cout << (int) res.size() << '\n';
for (int i : res) {
cout << i + 1 << " ";
}
cout << '\n';
} else {
vector<int> res;
for (int i = 0; i + 1 < n; i++) {
if (c[i] == 0) {
res.push_back(i);
}
}
if (c[n - 1]) {
res.push_back(n - 1);
}
cout << (int) res.size() << '\n';
for (int i : res) {
cout << i + 1 << " ";
}
cout << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer on the first run
input:
6 3 0 2 1 1 3 3 1 2 3 3 1 1 3 1 2 3 1 3
output:
3 1 2 3 0 0 2 2 3 2 1 3 2 1 2
input:
output:
result:
wrong answer Integer parameter [name=n] equals to 3, violates the range [2, 2] (test case 2)