Submission #368125

# Submission time Handle Problem Language Result Execution time Memory
368125 2021-02-19T15:34:36 Z leinad2 Rectangles (IOI19_rect) C++17
37 / 100
5000 ms 42324 KB
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int> > a)
{
    int n=a.size();
    int m=a[0].size();
    int i, j, k, l;
    long long ans=0;
    vector<pair<int, int> >v[2510];
    map<pair<int, int>, vector<int> >mp;
    for(i=1;i<n-1;i++)
    {
        for(j=0;j<m;j++)
        {
            l=-1;
            for(k=j+1;k<m;k++)
            {
                if(k>j+1)
                {
                    if(a[i][j]>l&&a[i][k]>l)
                    {
                        v[i].push_back({j, k});
                    }
                }
                l=max(l, a[i][k]);
            }
        }
    }
    for(j=1;j<m-1;j++)
    {
        for(i=0;i<n;i++)
        {
            l=-1;
            for(k=i+1;k<n;k++)
            {
                if(k>i+1)
                {
                    if(a[i][j]>l&&a[k][j]>l)
                    {
                        mp[{i, k}].push_back(j);
                    }
                }
                l=max(l, a[k][j]);
            }
        }
    }
    for(i=1;i<n-1;i++)
    {
        for(j=i;j<n-1;j++)
        {
            if(mp.find({i-1, j+1})==mp.end())continue;
            vector<int>V=mp[{i-1, j+1}];
            int A[2510]={};
            for(k=0;k<V.size();k++)A[V[k]]++;
            for(k=1;k<m;k++)
            {
                A[k]+=A[k-1];
            }
            map<pair<int, int>, int>mp2;
            for(k=i;k<=j;k++)
            {
                for(l=0;l<v[k].size();l++)
                {
                    mp2[v[k][l]]++;
                }
            }
            map<pair<int, int>, int>::iterator it;
            for(it=mp2.begin();it!=mp2.end();it++)
            {
                if(it->second==j-i+1)
                {
                    if(A[it->first.second-1]-A[it->first.first]==it->first.second-1-it->first.first)ans++;
                }
            }
        }
    }
	return ans;
}

Compilation message

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for(k=0;k<V.size();k++)A[V[k]]++;
      |                     ~^~~~~~~~~
rect.cpp:63:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |                 for(l=0;l<v[k].size();l++)
      |                         ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 4 ms 492 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 4 ms 492 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 6 ms 620 KB Output is correct
23 Correct 6 ms 620 KB Output is correct
24 Correct 7 ms 620 KB Output is correct
25 Correct 9 ms 492 KB Output is correct
26 Correct 104 ms 748 KB Output is correct
27 Correct 121 ms 768 KB Output is correct
28 Correct 66 ms 876 KB Output is correct
29 Correct 9 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 4 ms 492 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 6 ms 620 KB Output is correct
18 Correct 6 ms 620 KB Output is correct
19 Correct 7 ms 620 KB Output is correct
20 Correct 9 ms 492 KB Output is correct
21 Correct 104 ms 748 KB Output is correct
22 Correct 121 ms 768 KB Output is correct
23 Correct 66 ms 876 KB Output is correct
24 Correct 9 ms 492 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 87 ms 1516 KB Output is correct
31 Correct 87 ms 1516 KB Output is correct
32 Correct 89 ms 1772 KB Output is correct
33 Correct 130 ms 1408 KB Output is correct
34 Correct 2710 ms 2432 KB Output is correct
35 Correct 2882 ms 2544 KB Output is correct
36 Correct 1272 ms 2176 KB Output is correct
37 Correct 1029 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 4 ms 492 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 6 ms 620 KB Output is correct
18 Correct 6 ms 620 KB Output is correct
19 Correct 7 ms 620 KB Output is correct
20 Correct 9 ms 492 KB Output is correct
21 Correct 104 ms 748 KB Output is correct
22 Correct 121 ms 768 KB Output is correct
23 Correct 66 ms 876 KB Output is correct
24 Correct 9 ms 492 KB Output is correct
25 Correct 87 ms 1516 KB Output is correct
26 Correct 87 ms 1516 KB Output is correct
27 Correct 89 ms 1772 KB Output is correct
28 Correct 130 ms 1408 KB Output is correct
29 Correct 2710 ms 2432 KB Output is correct
30 Correct 2882 ms 2544 KB Output is correct
31 Correct 1272 ms 2176 KB Output is correct
32 Correct 1029 ms 2168 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Execution timed out 5097 ms 42324 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 748 KB Output is correct
2 Correct 5 ms 620 KB Output is correct
3 Correct 10 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 8 ms 620 KB Output is correct
6 Correct 8 ms 620 KB Output is correct
7 Correct 8 ms 620 KB Output is correct
8 Correct 8 ms 620 KB Output is correct
9 Correct 11 ms 620 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Execution timed out 5093 ms 35580 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 4 ms 492 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 6 ms 620 KB Output is correct
18 Correct 6 ms 620 KB Output is correct
19 Correct 7 ms 620 KB Output is correct
20 Correct 9 ms 492 KB Output is correct
21 Correct 104 ms 748 KB Output is correct
22 Correct 121 ms 768 KB Output is correct
23 Correct 66 ms 876 KB Output is correct
24 Correct 9 ms 492 KB Output is correct
25 Correct 87 ms 1516 KB Output is correct
26 Correct 87 ms 1516 KB Output is correct
27 Correct 89 ms 1772 KB Output is correct
28 Correct 130 ms 1408 KB Output is correct
29 Correct 2710 ms 2432 KB Output is correct
30 Correct 2882 ms 2544 KB Output is correct
31 Correct 1272 ms 2176 KB Output is correct
32 Correct 1029 ms 2168 KB Output is correct
33 Execution timed out 5097 ms 42324 KB Time limit exceeded
34 Halted 0 ms 0 KB -