fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. using namespace std;
  5.  
  6. void solve() {
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n, m, k;
  11. cin >> n >> m >> k;
  12.  
  13. vector<int> a(m);
  14. for (int i = 0; i < m; ++i) {
  15. cin >> a[i];
  16. }
  17.  
  18. set<int> knownQuestions;
  19. for (int i = 0; i < k; ++i) {
  20. int q;
  21. cin >> q;
  22. knownQuestions.insert(q);
  23. }
  24.  
  25. if(n >= k+2){
  26. for(int i = 0; i < m; i++){
  27. cout << 0;
  28. }
  29. }
  30. else if(n <= k){
  31. for(int i = 0; i < m; i++){
  32. cout << 1;
  33. }
  34. }
  35. else{
  36. string result;
  37. for (int i = 0; i < m; ++i) {
  38. if (knownQuestions.size() == n - 1 && knownQuestions.count(a[i]) == 0) {
  39. result += '1';
  40. } else {
  41. result += '0';
  42. }
  43. }
  44.  
  45. cout << result;
  46. }
  47. cout <<"\n";
  48. }
  49. }
  50.  
  51. int main() {
  52. ios::sync_with_stdio(false);
  53. cin.tie(nullptr);
  54.  
  55. solve();
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0s 5280KB
stdin
4
4 4 3
1 2 3 4
1 3 4
5 4 3
1 2 3 4
1 3 4
4 4 4
1 2 3 4
1 2 3 4
2 2 1
1 2
2
stdout
0100
0000
1111
10