Submission #891481

# Submission time Handle Problem Language Result Execution time Memory
891481 2023-12-23T05:35:38 Z Muhammad_Aneeq Rectangles (IOI19_rect) C++17
25 / 100
5000 ms 141864 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <vector>
#include <iostream>
using namespace std;
int const N=2600;
struct segt
{
	vector<int>a;
	int seg[4*N];
	segt(vector<int>&s)
	{
		a=s;
		build(1,0,a.size()-1);
	}	
	void build(int i,int st,int en)
	{
		if (st==en)
		{
			seg[i]=a[st];
			return;
		}
		int mid=(st+en)/2;
		build(i*2,st,mid);build(i*2+1,mid+1,en);
		seg[i]=max(seg[i*2],seg[i*2+1]);
	}
	int get(int i,int l,int r,int st,int en)
	{
		if (st>=l&&en<=r)
			return seg[i];
		if (st>r||en<l)
			return 0;
		int mid=(st+en)/2;
		return max(get(i*2,l,r,st,mid),get(i*2+1,l,r,mid+1,en));
	}
};
segt* St[2][N]={NULL};
long long count_rectangles(vector<vector<int>>a)
{
	int n=a.size(),m=a[0].size();
	for (int i=0;i<n;i++)
		St[0][i]=new segt(a[i]);
	for (int i=0;i<m;i++)
	{
		vector<int>z;
		for (int j=0;j<n;j++)
			z.push_back(a[j][i]);
		St[1][i]=new segt(z);
	}
	long long ans=0;
	for (int i=1;i<n-1;i++)
	{
		for (int j=1;j<m-1;j++)
		{
			for (int k=i;k<n-1;k++)
			{
				for (int l=j;l<m-1;l++)
				{
					bool w=0;
					for (int o=i;o<=k&&!w;o++)
					{
						int f=St[0][o]->get(1,j,l,0,m-1);
						if (f>=a[o][j-1]||f>=a[o][l+1])
							w=1;
					}
					for (int o=j;o<=l&&!w;o++)
					{
						int f=St[1][o]->get(1,i,k,0,n-1); 
						if (f>=a[i-1][o]||f>=a[k+1][o])
							w=1;
					}
					ans+=(!w);
				}
			}
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 696 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 6 ms 712 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 5 ms 692 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 696 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 6 ms 712 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 5 ms 692 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 525 ms 1388 KB Output is correct
23 Correct 523 ms 1400 KB Output is correct
24 Correct 515 ms 1396 KB Output is correct
25 Correct 377 ms 1616 KB Output is correct
26 Correct 376 ms 1116 KB Output is correct
27 Correct 370 ms 1616 KB Output is correct
28 Correct 383 ms 1372 KB Output is correct
29 Correct 85 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 696 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 6 ms 712 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 525 ms 1388 KB Output is correct
18 Correct 523 ms 1400 KB Output is correct
19 Correct 515 ms 1396 KB Output is correct
20 Correct 377 ms 1616 KB Output is correct
21 Correct 376 ms 1116 KB Output is correct
22 Correct 370 ms 1616 KB Output is correct
23 Correct 383 ms 1372 KB Output is correct
24 Correct 85 ms 1108 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 5 ms 692 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Execution timed out 5015 ms 3672 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 696 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 6 ms 712 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 525 ms 1388 KB Output is correct
18 Correct 523 ms 1400 KB Output is correct
19 Correct 515 ms 1396 KB Output is correct
20 Correct 377 ms 1616 KB Output is correct
21 Correct 376 ms 1116 KB Output is correct
22 Correct 370 ms 1616 KB Output is correct
23 Correct 383 ms 1372 KB Output is correct
24 Correct 85 ms 1108 KB Output is correct
25 Execution timed out 5015 ms 3672 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 310 ms 10984 KB Output is correct
2 Correct 209 ms 9412 KB Output is correct
3 Correct 277 ms 10844 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 278 ms 10984 KB Output is correct
6 Correct 285 ms 11092 KB Output is correct
7 Correct 277 ms 10840 KB Output is correct
8 Correct 278 ms 11088 KB Output is correct
9 Correct 277 ms 10844 KB Output is correct
10 Correct 6 ms 10844 KB Output is correct
11 Correct 5 ms 10840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 692 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 5081 ms 141864 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 696 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 712 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 6 ms 604 KB Output is correct
10 Correct 6 ms 712 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 352 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 525 ms 1388 KB Output is correct
18 Correct 523 ms 1400 KB Output is correct
19 Correct 515 ms 1396 KB Output is correct
20 Correct 377 ms 1616 KB Output is correct
21 Correct 376 ms 1116 KB Output is correct
22 Correct 370 ms 1616 KB Output is correct
23 Correct 383 ms 1372 KB Output is correct
24 Correct 85 ms 1108 KB Output is correct
25 Execution timed out 5015 ms 3672 KB Time limit exceeded
26 Halted 0 ms 0 KB -