Submission #34320


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;
  field[y][x]=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 0
Code Size 1443 Byte
Status WA
Exec Time 149 ms
Memory 9976 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 18
WA × 40
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 23 ms 732 KB
00_sample_01.txt AC 21 ms 792 KB
00_sample_02.txt AC 21 ms 796 KB
00_sample_03.txt WA 21 ms 792 KB
00_sample_04.txt AC 21 ms 788 KB
00_sample_05.txt AC 22 ms 788 KB
01_rndsmall_00.txt AC 23 ms 896 KB
01_rndsmall_01.txt AC 21 ms 888 KB
01_rndsmall_02.txt AC 23 ms 796 KB
01_rndsmall_03.txt AC 22 ms 784 KB
01_rndsmall_04.txt WA 23 ms 776 KB
01_rndsmall_05.txt AC 22 ms 816 KB
01_rndsmall_06.txt AC 22 ms 784 KB
01_rndsmall_07.txt WA 23 ms 768 KB
01_rndsmall_08.txt AC 22 ms 788 KB
01_rndsmall_09.txt WA 22 ms 788 KB
01_rndsmall_10.txt WA 22 ms 748 KB
01_rndsmall_11.txt WA 23 ms 784 KB
01_rndsmall_12.txt AC 22 ms 788 KB
01_rndsmall_13.txt AC 24 ms 740 KB
01_rndsmall_14.txt AC 23 ms 792 KB
01_rndsmall_15.txt WA 23 ms 784 KB
01_rndsmall_16.txt WA 23 ms 792 KB
01_rndsmall_17.txt WA 23 ms 736 KB
01_rndsmall_18.txt WA 22 ms 784 KB
01_rndsmall_19.txt WA 26 ms 784 KB
02_rndmax_00.txt WA 125 ms 4988 KB
02_rndmax_01.txt WA 127 ms 5116 KB
02_rndmax_02.txt WA 130 ms 4860 KB
02_rndmax_03.txt WA 129 ms 5112 KB
02_rndmax_04.txt WA 130 ms 4984 KB
02_rndmax_05.txt WA 129 ms 5244 KB
02_rndmax_06.txt AC 142 ms 9088 KB
02_rndmax_07.txt WA 138 ms 9336 KB
02_rndmax_08.txt WA 127 ms 5108 KB
02_rndmax_09.txt WA 122 ms 5108 KB
02_rndmax_10.txt WA 128 ms 5120 KB
02_rndmax_11.txt WA 128 ms 5116 KB
02_rndmax_12.txt WA 127 ms 5112 KB
02_rndmax_13.txt WA 139 ms 8956 KB
02_rndmax_14.txt WA 149 ms 9976 KB
02_rndmax_15.txt WA 129 ms 4984 KB
02_rndmax_16.txt WA 130 ms 5888 KB
02_rndmax_17.txt WA 127 ms 5500 KB
02_rndmax_18.txt WA 127 ms 5248 KB
02_rndmax_19.txt WA 128 ms 5112 KB
03_rnd_00.txt WA 27 ms 884 KB
03_rnd_01.txt WA 46 ms 2320 KB
03_rnd_02.txt WA 44 ms 1664 KB
03_rnd_03.txt WA 49 ms 1976 KB
03_rnd_04.txt WA 51 ms 2804 KB
03_rnd_05.txt WA 28 ms 1184 KB
03_rnd_06.txt WA 66 ms 3712 KB
03_rnd_07.txt WA 37 ms 1516 KB
03_rnd_08.txt WA 81 ms 4600 KB
03_rnd_09.txt WA 70 ms 4220 KB
04_empty_00.txt AC 121 ms 4852 KB
05_maxret_00.txt AC 135 ms 4856 KB