fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t,n,m,i,j; cin >> t;
  6. map<int,pair<int,int>> cd;
  7. while(t--){
  8. cd.clear();
  9. cin >> n >> m >> i >> j;
  10. cd[abs(i-1) + abs(j-1)] = {1,1};
  11. cd[abs(i-1) + abs(j-m)] = {1,m};
  12. cd[abs(i-n) + abs(j-1)] = {n,1};
  13. cd[abs(i-n) + abs(j-m)] = {n,m};
  14.  
  15. auto it1 = cd.rbegin();
  16.  
  17. cout << "1 1 " << (it1->second).first << " " << (it1->second).second << endl;
  18.  
  19. }
  20.  
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5276KB
stdin
7
2 3 1 1
4 4 1 2
3 5 2 2
5 1 2 1
3 1 3 1
1 1 1 1
1000000000 1000000000 1000000000 50
stdout
1 1 2 3
1 1 4 4
1 1 3 5
1 1 5 1
1 1 1 1
1 1 1 1
1 1 1 1000000000