답안 #147114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147114 2019-08-27T14:14:04 Z Nucleist Rectangles (IOI19_rect) C++14
0 / 100
3 ms 504 KB
#include <bits/stdc++.h> 
#include "rect.h"
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
vector<vector<int>>floodfill;
ll topx,topy,botx,boty;
ll last;
ll n,m;
ll dir[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
void dfs(ll x,ll y)
{
	topx=max(topx,x),topy=max(topy,y),botx=min(botx,x),boty=min(boty,y);
	floodfill[x][y]=last;
	for (ll i = 0; i < 4; ++i)
	{
		ll nextx=x+dir[i][0],nexty=y+dir[i][1];
		if(floodfill[nextx][nexty]==0)
			dfs(nextx,nexty);
	}
}
ll count_rectangles(vector<vector<int>>X)
{
  //flash;
  n =  sz(X); // 2 rows  
  m = sz(X[0]);
  floodfill=X;
  last=1;
  ll ans=0;
  for (ll i = 1; i < n-1; ++i)
  {
  	for (ll j = 1; j < m-1; ++j)
  	{
  		if(floodfill[i][j]==0)
  		{
  			last++;
  			topy=boty=j,topx=botx=i;
  			dfs(i,j);
  			ll topi = floodfill[topx][topy];
  			ll yopi = floodfill[topx][boty];
  			ll dopi = floodfill[botx][boty];
  			ll kopo = floodfill[botx][topy];
  			if(topi==yopi && yopi==dopi && dopi==kopo &&(topx!=n-1 && topy!=m-1 && botx!=0 && boty!=0))ans++;
  		}
  	}
  }
  return ans;
}
//code the AC sol !
// BS/queue/map
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -