fork download
  1. // Board Meeting problem. for N=1 // TLE
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main(){
  7. int T=1, N=1, M=1e6, R=1000;
  8. int x1,x2, y1,y2, d1,d2,a,x,y;
  9. string s;
  10. //cin>> T >> N >> M >> R;
  11. for(int i=1;i<=T; i++){
  12. cout<< "Test Case " << i << "\n";
  13. cout<< "enter distance to: "; ///
  14. cout<< -1000000 << " " << -1000000 << endl <<flush;
  15. cin>>s; //distance 1
  16. for(auto &x:s) x= toupper(x);
  17. if(s=="ERROR") return 0;
  18. else d1= stoi(s);
  19. cout<< "enter distance to: "; ///
  20. cout<< 1000000 << " " << 1000000 << endl <<flush;
  21. cin>>s; //distance 2
  22. for(auto &x:s) x= toupper(x);
  23. if(s=="ERROR")return 0;
  24. else d2= stoi(s);
  25. x1= -1000000 + d1;
  26. y1= 1000000 - d2;
  27. x2= 1000000 - d2;
  28. y2= -1000000 + d1;
  29. cout<< "enter distance to: "; ///
  30. cout<< x1 << " " << y1 << endl <<flush;
  31. cin >> a;
  32. if(a==0){x=x1; y=y1;}
  33. else{ x=x2; y=y2;}
  34. cout<< "x y : ";
  35. cout << x << " " << y << "\n"; ///
  36. cout<<"READY\n" <<flush;
  37. while(R--){
  38. cout<< "enter cordinate to see distance: ";
  39. cin>>s;
  40. for(auto &x:s) x= toupper(x);
  41. if(s=="DONE") break;
  42. if(s=="ERROR") return 0;
  43. x1= stoi(s);
  44. cin>>y1;
  45. x2 = abs(x-x1);
  46. y2 = abs(y-y1);
  47. if(x2>y2) cout<< x2 << endl << flush;
  48. else cout<< y2 << endl << flush;
  49. }
  50. }
  51. return 0;
  52. }
Success #stdin #stdout 0s 4372KB
stdin
1001000
999500
500
0 0
-1000 -1000
done
stdout
Test Case 1
enter distance to: -1000000 -1000000
enter distance to: 1000000 1000000
enter distance to: 1000 500
x y : 500 1000
READY
enter cordinate to see distance: 1000
enter cordinate to see distance: 2000
enter cordinate to see distance: