이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<ll>> rotate_matrix(vector<vector<ll>> cad)
{
vector<vector<ll>> sol(cad[0].size(),vector<ll>(cad.size(),0));
for (int i = 0; i < cad.size(); ++i)
for (int j = 0; j < cad[0].size(); ++j)
sol[j][cad.size() - 1 - i] = cad[i][j];
return sol;
}
int main()
{
ll n,m;
cin>>n>>m;
vector<vector<ll>> cad(n+2,vector<ll>(m+2,0));
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
cin>>cad[i][j];
ll bs=1e19;
for(int zxcv=0; zxcv<4; zxcv++)
{
n=cad.size();m=cad[0].size();
vector<vector<pair<ll,ll>>> t(n,vector<pair<ll,ll>>(m,{0,1e15}));
vector<pair<ll,ll>> sol;
multiset<ll> s;
for(int i=1; i<n-1; i++)
{
for(int j=1; j<m-1; j++)
{
t[i][j]={cad[i][j],cad[i][j]};
s.insert(cad[i][j]);
t[i][j].second=min(t[i][j].second,t[i][j-1].second);
t[i][j].second=min(t[i][j].second,t[i-1][j].second);
sol.push_back(t[i][j]);
}
}
sort(sol.begin(),sol.end());
reverse(sol.begin(),sol.end());
ll mini=sol[0].first;
for(int i=0; i<sol.size()-1; i++)
{
if(i>0) sol[i].second=min(sol[i].second,sol[i-1].second);
mini=min(mini,sol[i].second);
auto it = s.find(sol[i].first);
if (it != s.end()) {
s.erase(it);
}
if(s.size()!=0)
{
ll mayor = *s.rbegin();
bs=min(max(sol[0].first-mini,mayor-sol.back().first),bs);
}
}
cad=rotate_matrix(cad);
//cout<<bs<<"\n\n";
}
cout<<bs;
}
컴파일 시 표준 에러 (stderr) 메시지
joioi.cpp: In function 'std::vector<std::vector<long long int> > rotate_matrix(std::vector<std::vector<long long int> >)':
joioi.cpp:7:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | for (int i = 0; i < cad.size(); ++i)
| ~~^~~~~~~~~~~~
joioi.cpp:8:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for (int j = 0; j < cad[0].size(); ++j)
| ~~^~~~~~~~~~~~~~~
joioi.cpp: In function 'int main()':
joioi.cpp:20:11: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
20 | ll bs=1e19;
| ^~~~
joioi.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i=0; i<sol.size()-1; i++)
| ~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |