답안 #1037392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037392 2024-07-28T18:54:42 Z Marco_Escandon Rectangles (IOI19_rect) C++17
50 / 100
5000 ms 373076 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll su,iz,de, in;
ll contt;
vector<vector<ll>> v;
ll dfs(ll a, ll b)
{
    if(a==-1||b==-1||a==v.size()||b==v[0].size())
        return false;
    if(v[a][b]==1)
        return true;
    contt++;
    su=min(a,su);
    in=max(a,in);
    iz=min(b,iz);
    de=max(b,de);
    v[a][b]=1;
    ll pl= true;
    if(dfs(a+1,b)==false) pl= false;
    if(dfs(a,b+1)==false) pl= false;
    if(dfs(a-1,b)==false) pl= false;
    if(dfs(a,b-1)==false) pl= false;
    return pl;
}
long long count_rectangles(std::vector<std::vector<int> > a) {
    if(a.size()*a[0].size()<=705*705)
    {
        ll cont=0;
        ll n=a.size();ll m=a[0].size();
        for(int i=0; i<n-1; i++)
        {
            for(int j=0; j<m-1; j++)
            {
                for(int k=i+2; k<n; k++)
                {
                    for(int l=j+2; l<m; l++)
                    {
                        ll pl=1;
                        for(int o=i+1; o<k; o++)
                        {
                            for(int p=j+1; p<l; p++)
                            {
                                if(a[o][p]>=min(min(a[i][p],a[k][p]),min(a[o][j],a[o][l])))
                                {
                                    pl=0;
                                    goto fin1;
                                }
                            }
                        }
                        fin1:;
                        cont+=pl;
                    }
                }
            }
        }
        return cont;
    }
    ll cont=0;
    v.resize(a.size());
    for(int i=0; i<a.size(); i++)
    {
        v[i].resize(a[i].size());
        for(int j=0; j<a[0].size(); j++)
        {
            v[i][j]=a[i][j];
        }
    }
    for(int i=1; i<a.size()-1; i++)
    {
        for(int j=1; j<a[0].size()-1; j++)
        {
            if(v[i][j]==0)
            {
                su= 1000000;
                in= 0;
                iz=1000000;
                de= 0;
                contt=0;
                if(dfs(i,j)==false) continue;
                //cout<<(in-su+1)*(de-iz+1)<<" ";
                if(contt==(in-su+1)*(de-iz+1))
                {
                    cont++;
                    //cout<<i<<" "<< j<<"\n";
                }
 
            }
        }
    }
    return cont;
}

Compilation message

rect.cpp: In function 'll dfs(ll, ll)':
rect.cpp:9:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     if(a==-1||b==-1||a==v.size()||b==v[0].size())
      |                      ~^~~~~~~~~~
rect.cpp:9:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     if(a==-1||b==-1||a==v.size()||b==v[0].size())
      |                                   ~^~~~~~~~~~~~~
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0; i<a.size(); i++)
      |                  ~^~~~~~~~~
rect.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         for(int j=0; j<a[0].size(); j++)
      |                      ~^~~~~~~~~~~~
rect.cpp:69:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for(int i=1; i<a.size()-1; i++)
      |                  ~^~~~~~~~~~~
rect.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for(int j=1; j<a[0].size()-1; j++)
      |                      ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 26 ms 348 KB Output is correct
23 Correct 26 ms 348 KB Output is correct
24 Correct 27 ms 344 KB Output is correct
25 Correct 19 ms 348 KB Output is correct
26 Correct 28 ms 344 KB Output is correct
27 Correct 21 ms 348 KB Output is correct
28 Correct 21 ms 348 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 26 ms 348 KB Output is correct
18 Correct 26 ms 348 KB Output is correct
19 Correct 27 ms 344 KB Output is correct
20 Correct 19 ms 348 KB Output is correct
21 Correct 28 ms 344 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 21 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 943 ms 860 KB Output is correct
31 Correct 961 ms 856 KB Output is correct
32 Correct 939 ms 856 KB Output is correct
33 Correct 682 ms 604 KB Output is correct
34 Correct 743 ms 1112 KB Output is correct
35 Correct 714 ms 1040 KB Output is correct
36 Correct 735 ms 856 KB Output is correct
37 Correct 718 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 26 ms 348 KB Output is correct
18 Correct 26 ms 348 KB Output is correct
19 Correct 27 ms 344 KB Output is correct
20 Correct 19 ms 348 KB Output is correct
21 Correct 28 ms 344 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 21 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 943 ms 860 KB Output is correct
26 Correct 961 ms 856 KB Output is correct
27 Correct 939 ms 856 KB Output is correct
28 Correct 682 ms 604 KB Output is correct
29 Correct 743 ms 1112 KB Output is correct
30 Correct 714 ms 1040 KB Output is correct
31 Correct 735 ms 856 KB Output is correct
32 Correct 718 ms 856 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Execution timed out 5062 ms 7304 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 6 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Correct 9 ms 348 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
8 Correct 8 ms 348 KB Output is correct
9 Correct 8 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 704 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 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 88 ms 50968 KB Output is correct
8 Correct 188 ms 110160 KB Output is correct
9 Correct 203 ms 110940 KB Output is correct
10 Correct 187 ms 110672 KB Output is correct
11 Correct 176 ms 139252 KB Output is correct
12 Correct 466 ms 319472 KB Output is correct
13 Correct 442 ms 373076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 26 ms 348 KB Output is correct
18 Correct 26 ms 348 KB Output is correct
19 Correct 27 ms 344 KB Output is correct
20 Correct 19 ms 348 KB Output is correct
21 Correct 28 ms 344 KB Output is correct
22 Correct 21 ms 348 KB Output is correct
23 Correct 21 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 943 ms 860 KB Output is correct
26 Correct 961 ms 856 KB Output is correct
27 Correct 939 ms 856 KB Output is correct
28 Correct 682 ms 604 KB Output is correct
29 Correct 743 ms 1112 KB Output is correct
30 Correct 714 ms 1040 KB Output is correct
31 Correct 735 ms 856 KB Output is correct
32 Correct 718 ms 856 KB Output is correct
33 Execution timed out 5062 ms 7304 KB Time limit exceeded
34 Halted 0 ms 0 KB -