이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pi pair<ll,ll>
#define mid (l+r)/2
#define pb push
using namespace std;
const ll inf = 2e3+9,MX = 1e9+9;
ll n,m,ts,OriginalArr[inf][inf],a[inf][inf],mn = MX,mx,vis[inf][inf];
pi MaxVals;
queue<ll> q;
bool check(ll k,bool ReverseRow,bool ReverseCol){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
a[i][j] = OriginalArr[ (ReverseCol?n-i+1:i) ][ (ReverseRow?m-j+1:j) ];
int Col = 1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
if(a[i][j] > mn+k)
Col = max(Col,j+1);
for(int j=1;j<Col;j++)
if(a[i][j] < mx-k)
return 0;
}
return 1;
}
signed main(){
scanf("%lld%lld",&n,&m);
for(ll i=1;i<=n;i++){
for(ll j=1;j<=m;j++){
scanf("%lld",&OriginalArr[i][j]);
mx = max(mx,OriginalArr[i][j]);
mn = min(mn,OriginalArr[i][j]);
}
}
ll l = -1, r = mx-mn;
while(r-l>1){
if(check(mid,0,0) || check(mid,1,0) || check(mid,0,1) || check(mid,1,1))
r = mid;
else
l = mid;
}
printf("%lld\n",r);
}
컴파일 시 표준 에러 (stderr) 메시지
joioi.cpp: In function 'int main()':
joioi.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | scanf("%lld%lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~
joioi.cpp:33:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%lld",&OriginalArr[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |