fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. struct node
  6. {
  7. int x,y;
  8. node(int x1,int y1)
  9. {
  10. x=x1;
  11. y=y1;
  12. }
  13. };
  14.  
  15. int main() {
  16.  
  17. int n;
  18. cin>>n;
  19.  
  20. vector<node*> V;
  21. for(int i=0;i<n;i++)
  22. {
  23. int x,y;
  24. cin>>x>>y;
  25. V.push_back(new node(x,y));
  26. }
  27.  
  28. for(int i=0;i<n;i++)
  29. {
  30. int flag=0;
  31. for(int j=0;j<n;j++)
  32. {
  33. if(i!=j && V[i]->x <= V[j]->x && V[i]->y >= V[j]->y)
  34. {
  35. flag=1;
  36. }
  37. }
  38. if(flag == 1)
  39. {
  40. cout<<1<<" ";
  41. }
  42. else
  43. {
  44. cout<<0<<" ";
  45. }
  46. }
  47. cout<<endl;
  48.  
  49. for(int i=0;i<n;i++)
  50. {
  51. int flag=0;
  52. for(int j=0;j<n;j++)
  53. {
  54. if(i!=j && V[i]->x >= V[j]->x && V[i]->y <= V[j]->y)
  55. {
  56. flag=1;
  57. }
  58. }
  59. if(flag==1)
  60. {
  61. cout<<1<<" ";
  62. }
  63. else
  64. {
  65. cout<<0<<" ";
  66. }
  67. }
  68.  
  69.  
  70. return 0;
  71. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
1 6
2 4
4 8
3 6
stdout
1 0 0 0 
0 1 0 1