Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <map>
- #include <set>
- void sort(int* x,int* y, int low, int high);
- void swap(int& a,int& b );
- int min(int a,int b);
- int abs(int a);
- bool IsTrue(int x, int y, std::map<int, std::set<int>> map);
- int partition(int* x,int* y, int low, int high);
- int main(int argc, const char * argv[]) {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- std::map<int, std::set<int>> f;
- int *x,*y;
- int r,c;
- int n;
- fin>>r;
- fin>>c;
- fin>>n;
- x=new int[n];
- y=new int[n];
- for(int i=0;i<n;i++){
- fin>>y[i];
- fin>>x[i];
- f[x[i]].insert(y[i]);
- }
- sort(x, y, 0, n-1);
- for(int i=0;i<n;i++){
- fout<<x[i]<<" ";
- fout<<y[i]<<"\n";
- }
- for(int i=0;i<n-1;i++){
- for(int j=i+1; j<n; j++){
- int dx=x[i]-x[j],dy=y[i]-y[j];
- int minY=min(y[i],y[j]);
- if(dx==0){
- } else if()
- }
- }
- // fout<<maxPath;
- return 0;
- }
- bool IsTrue(int x, int y, std::map<int, std::set<int>> map)
- {
- if(map.count(x)!=0){
- if(map[x].count(y)!=0){
- return true;
- }
- }
- return false;
- }
- int min(int a,int b){
- return a<b ? a : b;
- }
- int abs(int a){
- return a>=0 ? a : -a;
- }
- int partition(int* x,int* y, int low, int high){
- int pivot = x[high];
- int i = (low - 1);
- for (int j = low; j < high; j++)
- {
- if (x[j] <= pivot)
- {
- i++;
- swap(x[i],x[j]);
- swap(y[i],y[j]);
- }
- }
- swap(x[i+1], x[high]);
- swap(y[i+1], y[high]);
- return i + 1;
- }
- void sort(int* x,int* y, int low, int high){
- if(low<high){
- int pi=partition(x, y, low, high);
- sort(x, y, low, pi-1);
- sort(x, y, pi+1, high);
- }
- }
- void swap(int&a,int& b){
- int temp=a;
- a=b;
- b=temp;
- }
- //int pivot = x[high];
- //int i = (low - 1);
- //for (int j = low; j < high; j++)
- //{
- // if (x[j] <= pivot)
- // {
- // i++;
- // swap(x[i],x[j]);
- // swap(y[i],y[j]);
- // }
- //}
- //swap(x[i+1], x[high]);
- //swap(x[i+1], x[high]);
- //return i + 1;
Advertisement
Add Comment
Please, Sign In to add comment