Advertisement
Saleh127

CF 1417b

Sep 27th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll x[200000];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. test
  13. {
  14. ll a[200000],c,d,e,f,i,j,k,l=1,n,t;
  15. cin>>n>>d;
  16. for(i=0; i<n; i++)
  17. {
  18. cin>>a[i];
  19. }
  20. if(d%2==0)
  21. {
  22. e=d/2;
  23. for(i=0; i<n; i++)
  24. {
  25. if(a[i]<e)
  26. {
  27. a[i]=1;
  28. }
  29. else if(e==a[i])
  30. {
  31. if(l==1)
  32. {
  33. a[i]=1;
  34. l=0;
  35. }
  36. else
  37. {
  38. a[i]=0;
  39. l=1;
  40. }
  41. }
  42. else
  43. {
  44. a[i]=0;
  45. }
  46. }
  47. }
  48. else
  49. {
  50. e=d/2+1;
  51. for(i=0; i<n; i++)
  52. {
  53. if(a[i]<e) a[i]=1;
  54. else a[i]=0;
  55. }
  56. }
  57. for(i=0; i<n; i++)
  58. {
  59. cout<<a[i]<<" ";
  60. }
  61. cout<<endl;
  62. }
  63.  
  64.  
  65. return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement