Advertisement
Ahmed_Negm

Untitled

Sep 29th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6. #define ll long long
  7. #define ull unsigned long long
  8. #define nl '\n'
  9. #define sz(x) int(x.size())
  10. #define all(x) x.begin(),x.end()
  11. #define rall(s)  s.rbegin(), s.rend()
  12. #define getline(s) getline(cin>>ws,s)
  13. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  14. #define pi  3.141592653589793
  15. #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  16. #define multi_ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
  17.  
  18.  
  19. void Fast_IO(){
  20. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  21. // freopen("filename.in", "r", stdin);
  22. // freopen("filename.txt", "w", stdout);
  23. #ifndef ONLINE_JUDGE
  24. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  25. #endif
  26. }
  27.  
  28. int x[8] = { 2, 1, -1, -2, -2, -1, 1, 2 };
  29. int y[8] = { 1, 2, 2, 1, -1, -2, -2, -1 };
  30.  
  31.  
  32.  
  33.  
  34. void solve(){
  35. ll n,m; cin>>n>>m;
  36. for(int i=0; i<n; i++)
  37.     for(int j=0; j<m; j++){
  38.         int cnt =0;
  39.         for(int k=0; k<8; k++){
  40.             int nx = i+x[k];
  41.             int ny = j+y[k];
  42.             if(nx>=0 && nx<n && ny>=0 && ny<m){
  43.             cnt++;
  44.             }
  45.         }
  46.         if(cnt ==0){
  47.             cout<<i+1<<' '<<j+1<<nl;
  48.             return;
  49.         }
  50.     }
  51. cout<<n<<' '<<m<<nl;
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58. int main(){
  59.     Fast_IO();
  60. int t =1;
  61. cin>>t;
  62. while(t--){
  63. solve();
  64. }
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement