이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#pragma GCC optimize("Ofast")
#pragma GCC target("tune=native")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define maxn 200000
#define BIG 1000000000000000000
mt19937 rnd(42);
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
auto st = steady_clock().now();
vector<vector<int> > a(n, vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
cin >> a[i][j];
}
int ans = -1e9;
for(int i = 0; i < 10; i++){
int bx = abs(int(rnd()))%n; int by = abs(int(rnd()))%m;
for(int o = 0; o < 30; o++){
int x = -1, y;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++){
int p = max(a[bx][by], a[i][j]) - min(a[bx][by], a[i][j]) - 1 - abs(i - bx) - abs(by - j);
if(p >= ans){
x = i;
y = j;
}
ans = max(ans, p);
}
if(x == -1)
break;
bx = x; by = y;
}
}
cout << ans;
}
/*
2 3
3 4 2
5 7 5
*/
컴파일 시 표준 에러 (stderr) 메시지
maxcomp.cpp: In function 'int main()':
maxcomp.cpp:31:10: warning: variable 'st' set but not used [-Wunused-but-set-variable]
auto st = steady_clock().now();
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |