Submission #67055

#TimeUsernameProblemLanguageResultExecution timeMemory
67055MrTEKMaxcomp (info1cup18_maxcomp)C++14
60 / 100
1089 ms52712 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define len(a) (int)a.size() #define fi first #define sc second #define d1(w) cerr<<#w<<":"<<w<<endl; #define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl; #define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl; #define left ind+ind #define right ind+ind+1 #define mid (l+r)/2 #define FAST_IO ios_base::sync_with_stdio(false); #define endl '\n' const int maxn = 620; const long long LINF = 1e18; const int LOG = 31; const int INF = 1e9; const int N = 1e3 + 5; const int M = 4; const int SQ = 350; const int MOD = 998244353; typedef pair <int,int> pii; set <pair <int,pii> > S; int n,m,mat[N][N],vis[N][N],ans = -INF,way[4][2] = {{1,0},{0,1},{0,-1},{-1,0}}; int main() { scanf("%d %d",&n,&m); for (int i = 1 ; i <= n ; i++) for (int j = 1 ; j <= m ; j++) { scanf("%d",&mat[i][j]); vis[i][j] = -INF; S.insert(mp(-mat[i][j],mp(i,j))); } while(len(S)) { auto temp = *S.begin(); S.erase(S.begin()); int val = -temp.fi, x = temp.sc.fi, y = temp.sc.sc; if (vis[x][y] > val) continue; ans = max(ans,val - mat[x][y] - 1); for (int i = 0 ; i < 4 ; i++) { int nx = x + way[i][0] , ny = y + way[i][1]; if (nx > 0 && nx <= n && ny > 0 && ny <= m && val - 1 > vis[nx][ny]) { vis[nx][ny] = val - 1; S.insert(mp(-(val - 1),mp(nx,ny))); } } } printf("%d\n",ans); }

Compilation message (stderr)

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
maxcomp.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&mat[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...