2 条题解

  • 0
    @ 2023-7-20 20:24:54
    #include <cstdio>
    using namespace std;
    int main(){
        int n,m,a[101][101];
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
        for(int i=2;i<n;i++)for(int j=2;j<m;j++)if(a[i][j]>a[i-1][j]&&a[i][j]>a[i+1][j]&&a[i][j]>a[i][j-1]&&a[i][j]>a[i][j+1])printf("%d\n",a[i][j]);
        return 0;
    }
    
    • 0
      @ 2023-7-16 10:22:40

      暴力枚举即可,时间复杂度O(n * m) AC代码!!!!!

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int m,n,a[105][105];
          cin >> n >> m;
          for (int i = 1;i <= n;i++)
          {
              for (int j = 1;j <= m;j++)
              {
                  cin >> a[i][j];
              }
          }
          for (int i = 2;i < n;i++)
          {
              for (int j = 2;j < n;j++)
              {
                  if (a[i][j] > a[i][j - 1] && a[i][j] > a[i][j + 1] && a[i][j] > a[i - 1][j] && a[i][j] > a[i + 1][j])
                  {
                      cout << a[i][j] << endl;
                  }
              }
          }
      }
      
      • 1

      信息

      ID
      381
      时间
      1000ms
      内存
      16MiB
      难度
      1
      标签
      递交数
      65
      已通过
      44
      上传者