Submission #34323


Source Code Expand

Copy
#include<iostream>
#include<vector>

int h,w;         
int getF(std::vector<std::vector<int> >& field,int y,int x,int s);

int main(){
  std::cin >> h >> w;
  std::vector<std::vector<int> > field;
  for(int i=0;i<h;i++){
    field.push_back(std::vector<int>());
    for(int j=0;j<w;j++){
      char c;
      std::cin >> c;
      if(c == '.')field[i].push_back(0);
      else field[i].push_back(1);
    }
  }
  int a=0,b=0,c=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(field[i][j]==1){
        int s=1;
        while(field[i+s][j+s]==1 && field[i+s][j]==1 && field[i][j+s]==1)s++;
        int p=getF(field,i,j,s);
        if(p==12)a++;
        if(p==16)b++;
        if(p==11)c++;
      }
    }
  }
  std::cout<<a<<" "<<b<<" "<<c<<std::endl;
  return 0;
}

int getF(std::vector<std::vector<int> >& field,int y,int x,int s){   
  int cnt=1;
  for(int i=0;i<s;i++){
    for(int j=0;j<s;j++){
      field[y+i][x+j]=0;
    }
  }
  if(y+s<h && field[y+s][x]==1)cnt+=getF(field,y+s,x,s);
  if(y>s-1 && field[y-s][x]==1)cnt+=getF(field,y-s,x,s);
  if(x+s<w && field[y][x+s]==1)cnt+=getF(field,y,x+s,s);
  if(x>s-1 && field[y][x-s]==1)cnt+=getF(field,y,x-s,s);
  if(y+s<h && x+s<w && field[y+s][x+s]==1)cnt+=getF(field,y+s,x+s,s);
  if(y>s-1 && x+s<w && field[y-s][x+s]==1)cnt+=getF(field,y-s,x+s,s);
  if(y+s<h && x>s-1 && field[y+s][x-s]==1)cnt+=getF(field,y+s,x-s,s);
  if(y>s-1 && x>s-1 && field[y-s][x-s]==1)cnt+=getF(field,y-s,x-s,s);
  return cnt;
}

Submission Info

Submission Time
Task D - アルファベット探し
User phi16
Language C++ (G++ 4.6.4)
Score 100
Code Size 1515 Byte
Status AC
Exec Time 137 ms
Memory 4888 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 58
Set Name Test Cases
All 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rndsmall_00.txt, 01_rndsmall_01.txt, 01_rndsmall_02.txt, 01_rndsmall_03.txt, 01_rndsmall_04.txt, 01_rndsmall_05.txt, 01_rndsmall_06.txt, 01_rndsmall_07.txt, 01_rndsmall_08.txt, 01_rndsmall_09.txt, 01_rndsmall_10.txt, 01_rndsmall_11.txt, 01_rndsmall_12.txt, 01_rndsmall_13.txt, 01_rndsmall_14.txt, 01_rndsmall_15.txt, 01_rndsmall_16.txt, 01_rndsmall_17.txt, 01_rndsmall_18.txt, 01_rndsmall_19.txt, 02_rndmax_00.txt, 02_rndmax_01.txt, 02_rndmax_02.txt, 02_rndmax_03.txt, 02_rndmax_04.txt, 02_rndmax_05.txt, 02_rndmax_06.txt, 02_rndmax_07.txt, 02_rndmax_08.txt, 02_rndmax_09.txt, 02_rndmax_10.txt, 02_rndmax_11.txt, 02_rndmax_12.txt, 02_rndmax_13.txt, 02_rndmax_14.txt, 02_rndmax_15.txt, 02_rndmax_16.txt, 02_rndmax_17.txt, 02_rndmax_18.txt, 02_rndmax_19.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt, 03_rnd_05.txt, 03_rnd_06.txt, 03_rnd_07.txt, 03_rnd_08.txt, 03_rnd_09.txt, 04_empty_00.txt, 05_maxret_00.txt
Case Name Status Exec Time Memory
00_min.txt AC 20 ms 788 KB
00_sample_01.txt AC 23 ms 788 KB
00_sample_02.txt AC 22 ms 788 KB
00_sample_03.txt AC 22 ms 788 KB
00_sample_04.txt AC 22 ms 820 KB
00_sample_05.txt AC 22 ms 796 KB
01_rndsmall_00.txt AC 22 ms 792 KB
01_rndsmall_01.txt AC 22 ms 784 KB
01_rndsmall_02.txt AC 23 ms 788 KB
01_rndsmall_03.txt AC 25 ms 788 KB
01_rndsmall_04.txt AC 23 ms 768 KB
01_rndsmall_05.txt AC 22 ms 788 KB
01_rndsmall_06.txt AC 23 ms 796 KB
01_rndsmall_07.txt AC 22 ms 796 KB
01_rndsmall_08.txt AC 22 ms 788 KB
01_rndsmall_09.txt AC 22 ms 764 KB
01_rndsmall_10.txt AC 22 ms 824 KB
01_rndsmall_11.txt AC 24 ms 764 KB
01_rndsmall_12.txt AC 21 ms 784 KB
01_rndsmall_13.txt AC 21 ms 788 KB
01_rndsmall_14.txt AC 21 ms 788 KB
01_rndsmall_15.txt AC 23 ms 792 KB
01_rndsmall_16.txt AC 23 ms 740 KB
01_rndsmall_17.txt AC 22 ms 784 KB
01_rndsmall_18.txt AC 23 ms 732 KB
01_rndsmall_19.txt AC 22 ms 736 KB
02_rndmax_00.txt AC 124 ms 4852 KB
02_rndmax_01.txt AC 124 ms 4888 KB
02_rndmax_02.txt AC 128 ms 4856 KB
02_rndmax_03.txt AC 127 ms 4860 KB
02_rndmax_04.txt AC 129 ms 4864 KB
02_rndmax_05.txt AC 123 ms 4852 KB
02_rndmax_06.txt AC 128 ms 4860 KB
02_rndmax_07.txt AC 120 ms 4864 KB
02_rndmax_08.txt AC 124 ms 4860 KB
02_rndmax_09.txt AC 126 ms 4832 KB
02_rndmax_10.txt AC 123 ms 4856 KB
02_rndmax_11.txt AC 123 ms 4860 KB
02_rndmax_12.txt AC 125 ms 4860 KB
02_rndmax_13.txt AC 121 ms 4864 KB
02_rndmax_14.txt AC 123 ms 4852 KB
02_rndmax_15.txt AC 127 ms 4860 KB
02_rndmax_16.txt AC 132 ms 4848 KB
02_rndmax_17.txt AC 122 ms 4860 KB
02_rndmax_18.txt AC 124 ms 4860 KB
02_rndmax_19.txt AC 125 ms 4856 KB
03_rnd_00.txt AC 25 ms 868 KB
03_rnd_01.txt AC 46 ms 2168 KB
03_rnd_02.txt AC 45 ms 1664 KB
03_rnd_03.txt AC 47 ms 1776 KB
03_rnd_04.txt AC 57 ms 2680 KB
03_rnd_05.txt AC 28 ms 1148 KB
03_rnd_06.txt AC 64 ms 3704 KB
03_rnd_07.txt AC 35 ms 1404 KB
03_rnd_08.txt AC 75 ms 3704 KB
03_rnd_09.txt AC 70 ms 4092 KB
04_empty_00.txt AC 122 ms 4848 KB
05_maxret_00.txt AC 137 ms 4860 KB