Submission #197084

#TimeUsernameProblemLanguageResultExecution timeMemory
197084ZhmyhMaxcomp (info1cup18_maxcomp)C++17
100 / 100
179 ms17204 KiB
#include <bits/stdc++.h> #define FI(_n) for(int i = 0; i < _n; ++i) #define FJ(_n) for(int j = 0; j < _n; ++j) #define mp make_pair #define pb push_back #define endl '\n' #ifdef LOCAL #define dbg(...) fprintf(stderr, __VA_ARGS__) #else #define LOCAL 0 #define dbg(...) #endif #define cerr if (!LOCAL) {} else std::cerr using ll = long long; using ull = unsigned long long; using ld = long double; using namespace std; int Get(vector<vector<int>> a) { int n = a.size(); int m = a.back().size(); /// minimizing min - x - y int best = -1; FI(n) { FJ(m) { int mn = min(a[i][j] - i - j, min(i ? a[i - 1][j] : INT_MAX, j ? a[i][j - 1] : INT_MAX)); best = max(best, a[i][j] - i - j - mn - 1); a[i][j] = mn; } } return best; } void LeftRight(vector<vector<int>>& a) { FI(a.size()) reverse(a[i].begin(), a[i].end()); } void UpDown(vector<vector<int>>& a) { reverse(a.begin(), a.end()); } int main() { #if !LOCAL ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // ifstream cin("input.txt"); // ofstream cout("output.txt"); #endif int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); FI(n) FJ(m) cin >> a[i][j]; int ans = INT_MIN; ans = max(ans, Get(a)); LeftRight(a); ans = max(ans, Get(a)); UpDown(a); ans = max(ans, Get(a)); LeftRight(a); ans = max(ans, Get(a)); cout << ans; dbg("\nIt took %f ms to run.", 1000.0 * clock() / CLOCKS_PER_SEC); return 0; }

Compilation message (stderr)

maxcomp.cpp: In function 'void LeftRight(std::vector<std::vector<int> >&)':
maxcomp.cpp:2:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FI(_n) for(int i = 0; i < _n; ++i)
                               ~~^~~~~~~~~~~
 #define FJ(_n) for(int j = 0; j < _n; ++j)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #define mp make_pair
 ~~~~~~~~~~~~~~~~~~~~~            
 #define pb push_back
 ~~~~~~~~~~~~~~~~~~~~~            
 #define endl '\n'
 ~~~~~~~~~~~~~~~~~~               
 
 ~                                
 #ifdef LOCAL
 ~~~~~~~~~~~~~                    
     #define dbg(...) fprintf(stderr, __VA_ARGS__)
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #else
 ~~~~~~                           
     #define LOCAL 0
     ~~~~~~~~~~~~~~~~             
     #define dbg(...)
     ~~~~~~~~~~~~~~~~~            
 #endif
 ~~~~~~~                          
 #define cerr if (!LOCAL) {} else std::cerr
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                
 using ll = long long;
 ~~~~~~~~~~~~~~~~~~~~~~           
 using ull = unsigned long long;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 using ld = long double;
 ~~~~~~~~~~~~~~~~~~~~~~~~         
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~            
 
 ~                                
 int Get(vector<vector<int>> a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 {
 ~~                               
     int n = a.size();
     ~~~~~~~~~~~~~~~~~~           
     int m = a.back().size();
     ~~~~~~~~~~~~~~~~~~~~~~~~~    
 
 ~                                
     /// minimizing min - x - y
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~  
     int best = -1;
     ~~~~~~~~~~~~~~~              
     FI(n)
     ~~~~~~                       
     {
     ~~                           
         FJ(m)
         ~~~~~~                   
         {
         ~~                       
             int mn = min(a[i][j] - i - j, min(i ? a[i - 1][j] : INT_MAX, j ? a[i][j - 1] : INT_MAX));
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             best = max(best, a[i][j] - i - j - mn - 1);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             a[i][j] = mn;
             ~~~~~~~~~~~~~~       
         }
         ~~                       
     }
     ~~                           
 
 ~                                
     return best;
     ~~~~~~~~~~~~~                
 }
 ~~                               
 
 ~                                
 void LeftRight(vector<vector<int>>& a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 {
 ~~                               
     FI(a.size())
     ~~~~~~~~~~~                  
maxcomp.cpp:43:5: note: in expansion of macro 'FI'
     FI(a.size())
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...