| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 37241 | wasyl | Tetris (COCI17_tetris) | C++11 | 0 ms | 2188 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <iostream>
#include <algorithm>
#define d(...) __VA_ARGS__
#define all(x) (x).begin(), (x).end()
#define eb(...) emplace_back(__VA_ARGS__)
using namespace std;using ll=long long;
template<class t>using V = vector< t >;
const int INF = 1e9 + 1;
struct Cords
{
	int x, y;
	Cords() : x( INF ), y( INF ) {}
	Cords( int x, int y ) : x( x ), y( y ) {}
};
inline Cords operator+ ( const Cords& a, const Cords& b )
{
	return Cords( a.x + b.x, a.y + b.y );
}
inline Cords operator- ( const Cords& a, const Cords& b )
{
	return Cords( a.x - b.x, a.y - b.y );
}
inline bool operator< ( const Cords& a, const Cords& b )
{
	return a.x == b.x? a.y < b.y : a.x < b.x;
}
inline bool operator== ( const Cords& a, const Cords& b )
{
	return a.x == b.x and a.y == b.y;
}
inline bool operator== ( const V< Cords >& a, const V< Cords >& b )
{
	if ( a.size() != b.size() ) return false;
	for ( int i = 0; i < a.size(); ++i )
		if ( !( a[i] == b[i] ) ) return false;
	return true;
}
inline V< V< char > > obroc ( const V< V< char > >& tab )
{
	V< V< char > > res ( tab[0].size(), V< char >( tab.size() ) );
	
	for ( int i = 0; i < res.size(); ++i )
		for ( int k = 0; k < res[i].size(); ++k )
			res[i][k] = tab[k][i];
	
	for ( int i = 0; i < res.size() / 2; ++i )
		for ( int k = 0; k < res[i].size(); ++k )
			swap( res[i][k], res[res.size() - 1 - i][k] );
	
	return res;
}
int n, m, t;
V< V< int > > odw;
V< V< char > > plane;	
V< V< Cords > > figures {
{ { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } },
{ { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 } },
{ { 0, 0 }, { 0, 1 }, { 1, -1 }, { 1, 0 } },
{ { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 2 } },
{ { 0, 0 }, { 1, -1 }, { 1, 0 }, { 1, 1 } }
};
V< Cords > curr;
V< int > res ( 5, 0 );
V< Cords > sas { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
void dfs ( const Cords& a, const Cords& wz )
{
	odw[a.x][a.y] = t;
	curr.eb( a - wz );
	for ( auto s : sas )
	{
		auto na = a + s;
		if ( odw[na.x][na.y] < t and
			plane[a.x][a.y] == plane[na.x][na.y] )
			dfs( na, wz );
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	plane.resize( n + 2, V< char >( m + 2, '.' ) );	
	odw.resize( max( n + 2, m + 2 ), V< int >( max( n + 2, m + 2 ) ) );
	for ( int i = 1; i <= n; ++i )
	{
		string s; cin >> s;
		for ( int k = 1; k <= m; ++k )
			plane[i][k] = s[k - 1];
	}
	
	for ( int i = 0; i < 4; ++i )
	{
		for ( int i = 1; i < plane.size() - 1; ++i )
			for ( int k = 1; k < plane[i].size() - 1; ++k )
				if ( plane[i][k] != '.' )
				{
					++t;
					dfs( Cords( i, k ), Cords( i, k ) );
					sort( all( curr ) );
					for ( int i = 0; i < figures.size(); ++i )
						if ( figures[i] == curr )
							++res[i];
					curr.clear();
				}
		plane = obroc( plane );	
	}
	res[0] /= 4; res[1] /= 2; res[2] /= 2; res[3] /= 2;
	for ( int i = 0; i < res.size(); ++i )
		cout << res[i] << '\n';
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
