2 solutions

  • 5
    @ 2025-5-18 16:05:01
    #include<bits/stdc++.h> 
    using namespace std; 
    int main() 
    { 
      int h,w;
      cin>>h>>w;
      int r,c;
      cin>>r>>c;
      int res=0;
      if(r-1>=1) res++;
      if(r+1<=h) res++;
      if(c-1>=1) res++; 
      if(c+1<=w) res++;
      cout<<res; 
      return 0;
    }
    
    • 0
      @ 2025-10-8 14:16:16

      #include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; int c,d; cin>>c>>d; int s=0; if (c-1>=1) { s=s+1; } if(c+1<=a) { s=s+1; } if(d-1>=1) { s=s+1; } if(d+1<=b) { s=s+1; } cout<<s; return 0; }

      • 1

      Information

      ID
      2319
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      95
      Accepted
      43
      Uploaded By