Submission #3076686


Source Code Expand

Copy
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<stdio.h>


using namespace std;
int main(void)
{
	int h, w;
	cin >> h >> w;
	vector<vector<char> > v(h+1, vector<char>(w+1));
	int i, j,num;
	vector<int> n(h, 0);
	vector<int> m(w, 0);
	for (i = 0; i < h; i++)
	{
		for (j =0 ; j < w; j++)
		{
			cin >> v[i][j];
		}
	}
	for (i = 0; i < h; i++)
	{
		 num = 0;
		for (j = 0; j < w; j++)
		{
			if (v[i][j] == '.')
			{
				num++;
			}
			if (num == w)
			{
				n[i] = 1;
			}
		}
	}

	for (j = 0; j < w; j++)
	{
	    num = 0;
		for (i = 0; i < h; i++)
		{
			if (v[i][j] == '.')
			{
				num++;
			}
			if (num == h)
			{
				m[j] = 1;
			}
		}
	}

	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (n[i] == 1)
			{
				while(n[i]==1)
				i++;
			}
			if (m[j])
			{
				while(m[j]==1)
				j++;
			}
			if (i == h || j == w)
			{
				continue;
			}
			cout << v[i][j];
		}
		cout << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task B - Grid Compression
User kanta
Language C++ (GCC 5.4.1)
Score 200
Code Size 1026 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 2 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