답안 #936502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936502 2024-03-02T02:49:22 Z Marco_Escandon The Kingdom of JOIOI (JOI17_joioi) C++11
100 / 100
3053 ms 261948 KB
#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;
        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]};
                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);
            bs=min(max(sol[0].first-mini,sol[i+1].first-sol.back().first),bs);
        }
        cad=rotate_matrix(cad);
        //cout<<bs<<"\n\n";
    }
    cout<<bs;
}

Compilation message

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:39: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]
   39 |         for(int i=0; i<sol.size()-1; i++)
      |                      ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 436 KB Output is correct
16 Correct 13 ms 2960 KB Output is correct
17 Correct 23 ms 3420 KB Output is correct
18 Correct 22 ms 3428 KB Output is correct
19 Correct 22 ms 3416 KB Output is correct
20 Correct 20 ms 3244 KB Output is correct
21 Correct 26 ms 3692 KB Output is correct
22 Correct 29 ms 3428 KB Output is correct
23 Correct 28 ms 3684 KB Output is correct
24 Correct 24 ms 3304 KB Output is correct
25 Correct 31 ms 3664 KB Output is correct
26 Correct 25 ms 3608 KB Output is correct
27 Correct 25 ms 3676 KB Output is correct
28 Correct 30 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 436 KB Output is correct
16 Correct 13 ms 2960 KB Output is correct
17 Correct 23 ms 3420 KB Output is correct
18 Correct 22 ms 3428 KB Output is correct
19 Correct 22 ms 3416 KB Output is correct
20 Correct 20 ms 3244 KB Output is correct
21 Correct 26 ms 3692 KB Output is correct
22 Correct 29 ms 3428 KB Output is correct
23 Correct 28 ms 3684 KB Output is correct
24 Correct 24 ms 3304 KB Output is correct
25 Correct 31 ms 3664 KB Output is correct
26 Correct 25 ms 3608 KB Output is correct
27 Correct 25 ms 3676 KB Output is correct
28 Correct 30 ms 3416 KB Output is correct
29 Correct 2620 ms 233884 KB Output is correct
30 Correct 2534 ms 232828 KB Output is correct
31 Correct 2732 ms 245492 KB Output is correct
32 Correct 2760 ms 245728 KB Output is correct
33 Correct 2359 ms 223224 KB Output is correct
34 Correct 2749 ms 245976 KB Output is correct
35 Correct 3017 ms 261368 KB Output is correct
36 Correct 2606 ms 236880 KB Output is correct
37 Correct 3053 ms 261948 KB Output is correct