Submission #3074420


Source Code Expand

Copy
#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;

	string a[h];
	rep(i, h) cin >> a[i];

	bool b[h][w];
	rep(i, h) rep(j, w) b[i][j] = true;

	rep(i, h){
		bool flg = true;
		rep(j, w){
			if(a[i][j] == '#') {
				flg = false;
				// cout << i << "," << j << endl;
				break;
			}
		}

		if(flg){
			rep(j, w) b[i][j] = false;
		}
	}

	rep(j, w){
		bool flg = true;
		rep(i, h){
			if(a[i][j] == '#') {
				flg = false;
				break;
			}
		}

		if(flg){
			rep(i, h) b[i][j] = false;
		}
	}

	// rep(i, h) rep(j, w) cout << b[i][j] << (j == w-1 ? "\n": "");

	rep(i, h){
		bool flg = false;
		rep(j, w){
			if(b[i][j]) {
				flg = true;
				cout << (""s + a[i][j]);
			}
		}
		if(flg) cout << endl;
	}
}

Submission Info

Submission Time
Task B - Grid Compression
User misora192
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1057 Byte
Status
Exec Time 2 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 200 / 200 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
0_03.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 2 ms 256 KB
1_03.txt 2 ms 256 KB
1_04.txt 2 ms 256 KB
1_05.txt 2 ms 256 KB
1_06.txt 2 ms 256 KB
1_07.txt 2 ms 256 KB