Submission #67021

#TimeUsernameProblemLanguageResultExecution timeMemory
67021osmanorhanMaxcomp (info1cup18_maxcomp)C++17
100 / 100
361 ms27528 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <cmath> #include <climits> #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <cassert> #include <vector> #define all(x) x.begin() , x.end() #define fi first #define se second #define pb push_back #define umax( x , y ) x = max( x , (y) ) #define umin( x , y ) x = min( x , (y) ) #define For( i , a ) for(int i=1;i<=a;i++) #define ort (b+s)/2 #define y2 asrwjaelkf #define y1 asseopirwjaelkf #define set multiset using namespace std; typedef long long Lint; typedef double db; typedef pair<int,int> ii; typedef pair<int,char> ic; typedef pair<db,db> dd; typedef pair<int,ii> iii; typedef pair<ii,ii> i4; const int maxn = 1020; const int maxm = 1000020; const int MOd = 998244353; int ar[maxn][maxn]; bool used[maxn][maxn]; queue<iii> q; int yol[4][2] = {{1,0},{0,1},{-1,0},{0,-1}}; vector<iii> v; int main() { //freopen("asd.in","r",stdin); //freopen("output17.txt","w",stdout); int a, b; scanf("%d %d",&a,&b); for(int i=1;i<=a;i++) for(int j=1;j<=b;j++) { scanf("%d",&ar[i][j]); v.pb( iii( ar[i][j], ii( i, j ) ) ); } sort( all( v ) ); int last = v.size()-1; int ans = -1e9; q.push( v[last--] ); while( !q.empty() ) { int mal = q.front().fi; int x = q.front().se.fi; int y = q.front().se.se; q.pop(); if( used[x][y] ) continue; used[x][y]=1; while( last >= 0 && v[last].fi == mal ) q.push( v[last--] ); umax( ans, mal-ar[x][y]-1 ); for(int i=0;i<4;i++) { int gox = x + yol[i][0]; int goy = y + yol[i][1]; if( 0 < gox && gox <= a && 0 < goy && goy <= b && !used[gox][goy] ) q.push( iii( mal-1, ii( gox, goy ) ) ); } } cout << ans << endl; return 0; }

Compilation message (stderr)

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&a,&b);
     ~~~~~^~~~~~~~~~~~~~~
maxcomp.cpp:56:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&ar[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...