답안 #145365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145365 2019-08-19T17:33:49 Z MvC Rectangles (IOI19_rect) C++14
0 / 100
310 ms 96584 KB
#include "rect.h"
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e3+50;
const int mod=1e9+7;
using namespace std;
int n,m,a[nmax][nmax],i,j,lvv[nmax][nmax],lv[nmax][nmax],lh[nmax][nmax],lhh[nmax][nmax],l,rs;
ll count_rectangles(vector<vector<int> > A) 
{
	n=A.size(),m=A[0].size();
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)a[i][j]=A[i-1][j-1];
	for(i=1;i<=m;i++)
	{
		l=n+1;
		for(j=n;j>=1;j--)
		{
			lv[j][i]=l;
			if(a[j][i])l=j;
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=m;j>=1;j--)
		{
			if(lv[i][j+1]==lv[i][j] && a[i][j+1])lvv[i][j]=lvv[i][j+1];
			else lvv[i][j]=j;
		}
	}
	for(i=1;i<=n;i++)
	{
		l=m+1;
		for(j=m;j>=1;j--)
		{
			lh[i][j]=l;
			if(a[i][j])l=j;
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=n;j>=1;j--)
		{
			if(lh[j][i]==lh[j+1][i] && a[j+1][i])lhh[j][i]=lhh[j+1][i];
			else lhh[j][i]=j;
		}
	}
	for(i=2;i<n;i++)
	{
		for(j=2;j<m;j++)
		{
			if(!a[i][j] || !a[i-1][j+1])continue;
			//cout<<i<<" "<<j<<endl;
			if(lhh[i][j]!=lhh[i-1][j] && lh[i][j]!=m+1 && lv[i-1][j+1]!=n+1 && lh[i][j]>j+1 && lv[i-1][j+1]>i)
			{
				//cout<<i<<" "<<j<<endl;
				if(lvv[i-1][j+1]>=lh[i][j]-1 && lhh[i][j]==lv[i-1][j+1]-1)rs++;
			}
		}
	}
	return rs;
}

Compilation message

rect.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
rect.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 310 ms 96584 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -