Submission #923285

# Submission time Handle Problem Language Result Execution time Memory
923285 2024-02-07T05:03:07 Z vjudge1 Maxcomp (info1cup18_maxcomp) C++17
15 / 100
4 ms 2396 KB
// Отче наш, сущий на небесах! Да святится имя Твое; да приидет Царствие Твое; да будет воля Твоя и на земле, как на небе; хлеб наш насущный подавай нам на каждый день; и прости нам грехи наши, ибо и мы прощаем всякому должнику нашему; и не введи нас в искушение, но избавь нас от лукавого ML, TL, WA
#include <bits/stdc++.h>
 
#pragma optimize("Ofast")
#pragma target("avx2")
 
#define ll long long
#define ld long double
#define pii pair<int,int>
#define F first
#define S second
#define in insert
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(s) (int)s.size()
#define ppb pop_back
#define mem(a,i) memset(a,i,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define int ll
 
using namespace std;
 
const int MAX=1000+10;
const int N=1000+10;
const int inf=1e18;
const int mod=1e9+9;
const int B=2003;
const ld eps=1e-9;
 
const int dx[4]={0,0,1,-1};
const int dy[4]={-1,1,0,0};
 
int binpow(int a,int n){
  if(n==0)return 1;
  if(n%2==1)return a*binpow(a,n-1)%mod;
  int k=binpow(a,n/2);
  return (k*k)%mod;
}
 
int n,m;
int ans;
int a[MAX][MAX];
int d[MAX][MAX];

int good(int i,int j){
  return (1<=i&&i<=n&&1<=j&&j<=m);
}

void solve(int si,int sj){
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++)d[i][j]=inf;
  }
  d[si][sj]=0;
  queue<pii> q;
  q.push({si,sj});
  while(!q.empty()){
    int i=q.front().F;
    int j=q.front().S;
    q.pop();
    for(int k=0;k<4;k++){
      int ni=i+dx[k];
      int nj=j+dy[k];
      if(good(ni,nj)&&a[ni][nj]<=a[si][sj]&&d[ni][nj]==inf){
        d[ni][nj]=d[i][j]+1;
        q.push({ni,nj});
      }
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(a[i][j]<=a[si][sj]&&d[i][j]!=inf){
        ans=max(ans,-d[i][j]-1+a[si][sj]-a[i][j]);
      }
    }
  }
}
 
void solve(){
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cin>>a[i][j];
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      solve(i,j);
    }
  }
  cout<<ans<<"\n";
}
 
signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t=1;
  // cin>>t;
  while(t--){
    solve();
  }
}

Compilation message

maxcomp.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    4 | #pragma optimize("Ofast")
      | 
maxcomp.cpp:5: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    5 | #pragma target("avx2")
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2392 KB Output is correct
2 Correct 3 ms 2396 KB Output is correct
3 Correct 3 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -