YauhenMardan

Untitled

Mar 9th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #include <fstream>
  2. #include <map>
  3. #include <set>
  4.  
  5. void sort(int* x,int* y, int low, int high);
  6. void swap(int& a,int& b );
  7. int min(int a,int b);
  8. int abs(int a);
  9. bool IsTrue(int x, int y, std::map<int, std::set<int>> map);
  10.  
  11. int partition(int* x,int* y, int low, int high);
  12.  
  13. int main(int argc, const char * argv[]) {
  14. std::ifstream fin("input.txt");
  15. std::ofstream fout("output.txt");
  16. std::map<int, std::set<int>> f;
  17. int *x,*y;
  18. int r,c;
  19. int n;
  20. fin>>r;
  21. fin>>c;
  22. fin>>n;
  23. x=new int[n];
  24. y=new int[n];
  25. for(int i=0;i<n;i++){
  26. fin>>y[i];
  27. fin>>x[i];
  28. f[x[i]].insert(y[i]);
  29. }
  30.  
  31. sort(x, y, 0, n-1);
  32.  
  33. for(int i=0;i<n;i++){
  34. fout<<x[i]<<" ";
  35. fout<<y[i]<<"\n";
  36. }
  37.  
  38. for(int i=0;i<n-1;i++){
  39. for(int j=i+1; j<n; j++){
  40. int dx=x[i]-x[j],dy=y[i]-y[j];
  41. int minY=min(y[i],y[j]);
  42. if(dx==0){
  43.  
  44. } else if()
  45. }
  46. }
  47.  
  48. // fout<<maxPath;
  49. return 0;
  50. }
  51.  
  52. bool IsTrue(int x, int y, std::map<int, std::set<int>> map)
  53. {
  54.  
  55. if(map.count(x)!=0){
  56. if(map[x].count(y)!=0){
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62.  
  63. int min(int a,int b){
  64. return a<b ? a : b;
  65. }
  66.  
  67. int abs(int a){
  68. return a>=0 ? a : -a;
  69. }
  70.  
  71. int partition(int* x,int* y, int low, int high){
  72. int pivot = x[high];
  73. int i = (low - 1);
  74. for (int j = low; j < high; j++)
  75. {
  76. if (x[j] <= pivot)
  77. {
  78. i++;
  79. swap(x[i],x[j]);
  80. swap(y[i],y[j]);
  81. }
  82. }
  83. swap(x[i+1], x[high]);
  84. swap(y[i+1], y[high]);
  85. return i + 1;
  86. }
  87.  
  88. void sort(int* x,int* y, int low, int high){
  89. if(low<high){
  90. int pi=partition(x, y, low, high);
  91. sort(x, y, low, pi-1);
  92. sort(x, y, pi+1, high);
  93. }
  94. }
  95. void swap(int&a,int& b){
  96. int temp=a;
  97. a=b;
  98. b=temp;
  99. }
  100.  
  101. //int pivot = x[high];
  102. //int i = (low - 1);
  103. //for (int j = low; j < high; j++)
  104. //{
  105. // if (x[j] <= pivot)
  106. // {
  107. // i++;
  108. // swap(x[i],x[j]);
  109. // swap(y[i],y[j]);
  110. // }
  111. //}
  112. //swap(x[i+1], x[high]);
  113. //swap(x[i+1], x[high]);
  114. //return i + 1;
Advertisement
Add Comment
Please, Sign In to add comment