Submission #34296


Source Code Expand

Copy
#include <iostream>
using namespace std;

int h,w;
char c[1100][1100];

int di[8] = {-1,-1,-1, 0, 0, 1, 1,1};
int dj[8] = {-1, 0, 1, 1,-1, -1,0,1};

int d(int i,int j ){
  if( i<0 || i>=h ) return 0;
  if( j<0 || j>=w ) return 0;
  if( c[i][j]=='.' ) return 0;
  if( c[i][j]==',' ) return 0;

  c[i][j]=',';
  int rtn = 1;
  for( int l=0;l<8;l++ )
    rtn += d(i+di[l], j+dj[l]);
  return rtn;
}

int gcd(int a, int b){
  if( b==0 ) return a;
  return gcd(b,a%b);
}
int scale(int i,int j){
  int n[4] = {0,0,0,0};
  for( int a=j; a<w  && c[i][a]==','; a++ ) n[0]++;
  for( int a=j; a>=0 && c[i][a]==','; a-- ) n[1]++;
  for( int a=i; a<h  && c[a][j]==','; a++ ) n[2]++;
  for( int a=i; a>=0 && c[a][j]==','; a-- ) n[3]++;

  int sc = n[i];
  for( int i=1;i<4;i++ )
    sc = gcd( sc, n[i] );
  return sc;
}


int main(){
  cin >> h >> w;
  for( int i=0;i<h;i++ )
    for( int j=0;j<w;j++ )
      cin >> c[i][j];

  int an=0, bn=0, cn=0;
  bool fa, fb, fc;
  for( int i=0;i<h;i++ ){
    for( int j=0;j<w;j++ ){
      if( c[i][j]=='o' ){
	int nb = d(i,j);
	int sc = scale(i,j);
	nb = nb / sc;
	fa = nb%12==0;
	fb = nb%16==0;
	fc = nb%11==0;

	if( fa ) an++;
	else if( fb ) bn++;
	else if( fc ) cn++;
      }
    }
  }
  cout << an << " " << bn << " " << cn << endl;

  return 0;
}

Submission Info

Submission Time
Task D - アルファベット探し
User tkmhsy
Language C++ (G++ 4.6.4)
Score 0
Code Size 1346 Byte
Status WA
Exec Time 381 ms
Memory 11772 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 25
WA × 22
RE × 11
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 21 ms 796 KB
00_sample_01.txt AC 22 ms 784 KB
00_sample_02.txt AC 22 ms 820 KB
00_sample_03.txt AC 22 ms 760 KB
00_sample_04.txt AC 21 ms 816 KB
00_sample_05.txt AC 21 ms 792 KB
01_rndsmall_00.txt WA 21 ms 920 KB
01_rndsmall_01.txt AC 22 ms 884 KB
01_rndsmall_02.txt AC 23 ms 884 KB
01_rndsmall_03.txt WA 22 ms 900 KB
01_rndsmall_04.txt AC 21 ms 920 KB
01_rndsmall_05.txt AC 23 ms 892 KB
01_rndsmall_06.txt AC 21 ms 916 KB
01_rndsmall_07.txt AC 22 ms 920 KB
01_rndsmall_08.txt AC 22 ms 916 KB
01_rndsmall_09.txt AC 24 ms 904 KB
01_rndsmall_10.txt AC 23 ms 916 KB
01_rndsmall_11.txt WA 22 ms 920 KB
01_rndsmall_12.txt AC 23 ms 884 KB
01_rndsmall_13.txt AC 22 ms 900 KB
01_rndsmall_14.txt AC 23 ms 916 KB
01_rndsmall_15.txt WA 22 ms 916 KB
01_rndsmall_16.txt AC 23 ms 888 KB
01_rndsmall_17.txt AC 21 ms 940 KB
01_rndsmall_18.txt WA 22 ms 916 KB
01_rndsmall_19.txt WA 30 ms 912 KB
02_rndmax_00.txt WA 114 ms 2296 KB
02_rndmax_01.txt WA 120 ms 2304 KB
02_rndmax_02.txt RE 347 ms 1916 KB
02_rndmax_03.txt WA 121 ms 2168 KB
02_rndmax_04.txt RE 347 ms 1920 KB
02_rndmax_05.txt WA 119 ms 2420 KB
02_rndmax_06.txt RE 357 ms 11772 KB
02_rndmax_07.txt WA 124 ms 6132 KB
02_rndmax_08.txt WA 119 ms 2292 KB
02_rndmax_09.txt RE 348 ms 2168 KB
02_rndmax_10.txt RE 336 ms 2180 KB
02_rndmax_11.txt RE 361 ms 2808 KB
02_rndmax_12.txt RE 342 ms 2308 KB
02_rndmax_13.txt WA 141 ms 8444 KB
02_rndmax_14.txt RE 360 ms 11764 KB
02_rndmax_15.txt RE 343 ms 1776 KB
02_rndmax_16.txt WA 128 ms 3452 KB
02_rndmax_17.txt WA 117 ms 3456 KB
02_rndmax_18.txt RE 342 ms 2032 KB
02_rndmax_19.txt RE 381 ms 1884 KB
03_rnd_00.txt AC 24 ms 788 KB
03_rnd_01.txt WA 44 ms 1784 KB
03_rnd_02.txt AC 44 ms 1016 KB
03_rnd_03.txt WA 46 ms 1656 KB
03_rnd_04.txt WA 52 ms 1408 KB
03_rnd_05.txt AC 27 ms 892 KB
03_rnd_06.txt WA 62 ms 1396 KB
03_rnd_07.txt WA 32 ms 1012 KB
03_rnd_08.txt WA 79 ms 3848 KB
03_rnd_09.txt WA 246 ms 1424 KB
04_empty_00.txt AC 108 ms 1788 KB
05_maxret_00.txt AC 199 ms 1788 KB