답안 #316839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316839 2020-10-28T10:05:03 Z ronnith Tetris (COCI17_tetris) C++14
80 / 80
1 ms 512 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#warning Check Integer OverFlow
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define de cerr
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)/(__gcd(a,b))) * b)
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define v vector
#define p pair
#define pii p<int,int>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
ll modF=1e9+7;

/*OUTPUT

*/

int N,M;
char a[10][10];
int mr[10][10];

bool find(int x,int y,vector<pii> fig,char ch){
	bool pos = true;
	if(ch == '.'){
		pos = false;
	}
	for(auto e:fig){
		if(x + e.f < 0 or x + e.f >= N or y + e.s < 0 or y + e.s >= M or a[x + e.f][y + e.s] != ch){
			pos = false;
		}
	}
	if(pos){
		for(auto e:fig){
			// if(x + e.f < 0 or x + e.f >= N or y + e.s < 0 or y + e.s >= M or a[x + e.f][y + e.s] != ch){
				mr[x+ e.f][y + e.s] = 1;
			// }
		}
	}
	return pos;
}

void solve(){
	cin >> N >> M;
	rep(i,0,N){
		rep(j,0,M){
			cin >> a[i][j];
		}
	}
	int fr[] = {0,0,0,0,0,0,0,0};
	vector<pair<int,int>> figures[7];
	figures[0] = {{0,0},{1,0},{0,1},{1,1}};// square

	figures[1] = {{0,0},{0,1},{0,2},{0,3}};
	// line
	figures[2] = {{0,0},{1,0},{2,0},{3,0}};

	figures[3] = {{0,0},{0,1},{1,1},{1,2}};
	// zig 1
	figures[4] = {{0,0},{1,0},{0,1},{-1,1}};

	figures[5] = {{0,0},{0,1},{-1,1},{-1,2}};
	// zig 2
	figures[6] = {{0,0},{0,1},{1,1},{-1,0}};
	rep(i,0,N){
		rep(j,0,M){
			rep(k,0,7){
				if(find(i,j,figures[k],a[i][j])){
					debug3(i,j,k);
					de << ln;
					fr[k] ++;
				}
			}
		}
	}
	int um = 0;
	rep(i,0,N){
		rep(j,0,M){
			if(!mr[i][j] and a[i][j] != '.'){
				um ++;
			}
		}
	}
	fr[7] = um / 4;
	cout << fr[0] << ln << fr[1] + fr[2] << ln << fr[5] + fr[6] << ln << fr[3] + fr[4] << ln << fr[7] << ln;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int t = 1;
	// cin >> t;
	while(t --){
		solve();
	}
}

Compilation message

tetris.cpp:4:2: warning: #warning Check Integer OverFlow [-Wcpp]
    4 | #warning Check Integer OverFlow
      |  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct