Submission #1187147


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define fir first
#define sec second
// #define DEBUG

typedef long long LL;
typedef pair<int,int> pii;
pii g[3][3];
pii dir[9][9];
int ID[3][3];
int h, w, n;

inline bool judge(int x, int y) {
	return x<=0 || x>h || y<=0 || y>w;
}

inline bool judge(pii p) {
	return p.fir<=0 || p.fir>h || p.sec<=0 || p.sec>w;
}

void init() {
	int c = 0;

	for (int i=0; i<3; ++i) {
		for (int j=0; j<3; ++j) {
			g[i][j] = make_pair(i, j);
			ID[i][j] = c++;
		}
	}

	for (int id=0; id<9; ++id) {
		int x = id / 3;
		int y = id % 3;
		int z = 0;
		for (int i=0; i<3; ++i) {
			for (int j=0; j<3; ++j) {
				dir[id][z] = make_pair(g[i][j].fir-x, g[i][j].sec-y);
				++z;
			}
		}
	}

	// #ifdef DEBUG
	// for (int id=0; id<9; ++id) {
	// 	for (int i=0; i<9; ++i)
	// 		printf("(%d,%d) ", dir[id][i].fir, dir[id][i].sec);
	// 	putchar('\n');
	// }
	// #endif
}

int main() {
	LL c[10];
	pii p;
	init();

	scanf("%d %d %d", &h, &w, &n);
	set<pii> st;
	LL tot = 1LL * (h - 2) * (w - 2);
	for (int i=0; i<n; ++i) {
		scanf("%d %d", &p.fir, &p.sec);
		st.insert(p);
	}
	memset(c, 0, sizeof(c));

	int x, y, xx, yy, cnt;
	bool flag;

	for (auto iter=st.begin(); iter!=st.end(); ++iter) {
		x = iter->fir;
		y = iter->sec;
		for (int id=0; id<9; ++id) {
			flag = true;
			cnt = 0;
			for (int k=0; k<9; ++k) {
				p.fir = x + dir[id][k].fir;
				p.sec = y + dir[id][k].sec;
				if (judge(p.fir, p.sec)) {
					flag = false;
					break;
				}
				cnt += st.count(p)>0;

				// if (x==1 && y==1) {
				// 	printf("%d: %d %d\n", id, p.fir, p.sec);
				// }
			}
			if (flag)
				c[cnt]++;

			// #ifdef DEBUG
			// if (flag) 
			// 	printf("(%d, %d): %d = %d\n", x, y, id, cnt);
			// #endif
		}
	}

	c[0] = tot;
	for (int i=1; i<=9; ++i) {
		c[i] /= i;
		c[0] -= c[i];
	}

	for (int i=0; i<10; ++i) {
		cout << c[i] << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task D - Snuke's Coloring
User Trasier
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1976 Byte
Status AC
Exec Time 382 ms
Memory 4992 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:59:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &h, &w, &n);
                               ^
./Main.cpp:63:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &p.fir, &p.sec);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status AC
AC × 19
Set Name Test Cases
Sample
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, empty.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 382 ms 4992 KB
02.txt AC 356 ms 4992 KB
03.txt AC 89 ms 1408 KB
04.txt AC 1 ms 256 KB
05.txt AC 237 ms 4992 KB
06.txt AC 171 ms 4992 KB
07.txt AC 307 ms 4992 KB
08.txt AC 305 ms 4992 KB
09.txt AC 309 ms 4992 KB
10.txt AC 1 ms 256 KB
11.txt AC 356 ms 4992 KB
12.txt AC 320 ms 4992 KB
13.txt AC 2 ms 256 KB
14.txt AC 374 ms 4992 KB
15.txt AC 365 ms 4992 KB
empty.txt AC 1 ms 256 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB