Submission #34503


Source Code Expand

Copy
//template ver2.00
//------------------------------------------

//include
//------------------------------------------
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
template<class T> inline T is_inner(T x, T a, T b) {return a <= x && x < b;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define MP make_pair
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(c, e) ((c).find(e) != (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a);i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//IO
//------------------------------------------
#define LF(x) cout << (x) << endl;
#define LFA(a, n) cout << a[0]; FOR(itr, 1, n) {cout << " " << a[itr];} cout << endl;
#define LFP(x, w) cout << setprecision((w)); cout << setiosflags(ios::fixed); cout << (x) << endl;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1e9;
const int DI[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int DJ[] = {1, 1, 0, -1, -1, -1, 0, 1};

//clear memory
//--------------------------------------------
#define CLR(a) memset((a), 0 , sizeof(a))

//debug
//--------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DUMPA(a, n) cerr << #a << " = {" << a[0]; FOR(itr, 1, n) { cout << ", " << a[itr]; } cerr << "}" << endl;
#define DUMPAA(a, n, m) REP(itr, n) {REP(jtr, m) {cout << a[itr][jtr] << " ";} cout << endl;}

const int H = 1000;
const int W = 1000;

const int N[3] = {12, 16, 11};

int h, w;
char c[H][W];
int ans[3];


int dfs(int i, int j)
{
     if (!is_inner(i, 0, h) || !is_inner(j, 0, w) || c[i][j] == '.') return 0;
     c[i][j] = '.';
     int res = 1;
     REP(k, 8) res += dfs(i + DI[k], j + DJ[k]);
     return res;
}


void init()
{
}

void solve()
{
     CLR(ans);
     REP(i, h) REP(j, w) {
	  if (c[i][j] == 'o') {
	       int n = dfs(i, j);
	       REP(k, 3) {
		    int x = 1;
		    while (N[k] * x * x < n) ++x;
		    if (N[k] * x * x == n) ++ans[k];
	       }
	  }
     }
     cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
}

int main()
{
     init();
     cin >> h >> w;
     REP(i, h) cin >> c[i];
     solve();
     return 0;
}

Submission Info

Submission Time
Task D - アルファベット探し
User wotsushi
Language C++ (GCC 4.4.7)
Score 100
Code Size 3158 Byte
Status AC
Exec Time 100 ms
Memory 10236 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 23 ms 760 KB
00_sample_01.txt AC 21 ms 796 KB
00_sample_02.txt AC 21 ms 796 KB
00_sample_03.txt AC 22 ms 780 KB
00_sample_04.txt AC 22 ms 792 KB
00_sample_05.txt AC 22 ms 784 KB
01_rndsmall_00.txt AC 22 ms 912 KB
01_rndsmall_01.txt AC 22 ms 888 KB
01_rndsmall_02.txt AC 22 ms 892 KB
01_rndsmall_03.txt AC 22 ms 908 KB
01_rndsmall_04.txt AC 22 ms 884 KB
01_rndsmall_05.txt AC 22 ms 916 KB
01_rndsmall_06.txt AC 22 ms 896 KB
01_rndsmall_07.txt AC 22 ms 920 KB
01_rndsmall_08.txt AC 23 ms 776 KB
01_rndsmall_09.txt AC 20 ms 928 KB
01_rndsmall_10.txt AC 23 ms 916 KB
01_rndsmall_11.txt AC 22 ms 912 KB
01_rndsmall_12.txt AC 22 ms 908 KB
01_rndsmall_13.txt AC 21 ms 916 KB
01_rndsmall_14.txt AC 21 ms 916 KB
01_rndsmall_15.txt AC 20 ms 916 KB
01_rndsmall_16.txt AC 22 ms 864 KB
01_rndsmall_17.txt AC 22 ms 912 KB
01_rndsmall_18.txt AC 22 ms 892 KB
01_rndsmall_19.txt AC 22 ms 916 KB
02_rndmax_00.txt AC 75 ms 2036 KB
02_rndmax_01.txt AC 76 ms 2040 KB
02_rndmax_02.txt AC 80 ms 1784 KB
02_rndmax_03.txt AC 77 ms 2044 KB
02_rndmax_04.txt AC 78 ms 1792 KB
02_rndmax_05.txt AC 77 ms 2176 KB
02_rndmax_06.txt AC 97 ms 10236 KB
02_rndmax_07.txt AC 84 ms 5756 KB
02_rndmax_08.txt AC 76 ms 2160 KB
02_rndmax_09.txt AC 73 ms 2048 KB
02_rndmax_10.txt AC 73 ms 2168 KB
02_rndmax_11.txt AC 77 ms 2428 KB
02_rndmax_12.txt AC 76 ms 2168 KB
02_rndmax_13.txt AC 85 ms 5112 KB
02_rndmax_14.txt AC 100 ms 9340 KB
02_rndmax_15.txt AC 79 ms 1912 KB
02_rndmax_16.txt AC 78 ms 3324 KB
02_rndmax_17.txt AC 74 ms 3052 KB
02_rndmax_18.txt AC 72 ms 2176 KB
02_rndmax_19.txt AC 76 ms 2164 KB
03_rnd_00.txt AC 23 ms 796 KB
03_rnd_01.txt AC 34 ms 1532 KB
03_rnd_02.txt AC 33 ms 1028 KB
03_rnd_03.txt AC 34 ms 1404 KB
03_rnd_04.txt AC 38 ms 1276 KB
03_rnd_05.txt AC 25 ms 912 KB
03_rnd_06.txt AC 44 ms 1280 KB
03_rnd_07.txt AC 29 ms 1004 KB
03_rnd_08.txt AC 55 ms 3568 KB
03_rnd_09.txt AC 45 ms 1396 KB
04_empty_00.txt AC 68 ms 1652 KB
05_maxret_00.txt AC 90 ms 1660 KB