QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#300351#4825. Even and Odd Combinationswxhtzdy0 0ms0kbC++201.0kb2024-01-08 04:10:172024-01-08 04:10:18

Judging History

你现在查看的是最新测评结果

  • [2024-01-08 04:10:18]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-01-08 04:10:17]
  • 提交

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;
}

詳細信息

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)