Submission #3076306


Source Code Expand

Copy
#include <iostream>
#include <string>
using namespace std;
int h,w;
int H,W;
string s[109];
string S;
bool flag;
int main() {
  cin >> H>> W;
  h=0;
  w=W;

  for(int i=0;i<H;i++){
    cin >> S;
    flag=false;
    for (int j=0;j<W;j++){
      if(S.substr(j,1)=="#"){
        flag=true;
      }
    }
    if(flag){
      s[h]=S;
      h++;
    }
  }
  for(int i=W-1;i>=0;i--){
    flag=true;
    for(int j=0;j<h;j++){
      if(s[j].substr(i,1)=="#"){
        flag=false;
      }
    }
    if(flag){
      for(int k=0;k<h;k++){
        s[k].erase(i,1);
      }
    }
  }
  for(int i=0;i<h;i++){
    cout << s[i] << "\n";
  }
}

Submission Info

Submission Time
Task B - Grid Compression
User kinonotofu
Language C++14 (GCC 5.4.1)
Score 200
Code Size 667 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 12
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 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 AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 2 ms 256 KB
1_02.txt AC 3 ms 256 KB
1_03.txt AC 3 ms 256 KB
1_04.txt AC 2 ms 256 KB
1_05.txt AC 2 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 2 ms 256 KB