Submission #880566
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 7;
//-------head---------
const int dx[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
const int dy[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
int h, w, n;
set<pii> S;
set<pii>::iterator it;
ll ans[10];
int calc(int sx, int sy) {
int ret = 0;
rep(i, 0, 9) {
int x, y;
x = sx + dx[i];
y = sy + dy[i];
if (S.find(mp(x, y)) != S.end())
++ret;
}
return ret;
}
void solve() {
for (it = S.begin(); it != S.end(); ++it) {
rep(i, 0, 9) {
int x, y;
x = it->first + dx[i];
y = it->second + dy[i];
if (x < 2 || x > h - 1 || y < 2 || y > w - 1)
continue;
++ans[calc(x, y)];
}
}
ans[0] = 1ll * (h -2) * (w - 2);
rep(i, 1, 10) {
ans[i] /= i;
ans[0] -= ans[i];
}
}
int main() {
cin >> h >> w >> n;
rep(i, 0, n) {
int a, b;
cin >> a >> b;
S.insert(mp(a, b));
}
solve();
rep(i, 0, 10)
cout << ans[i] << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Snuke's Coloring |
User |
mcginn |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1224 Byte |
Status |
AC |
Exec Time |
789 ms |
Memory |
4992 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
AC
|
|
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 |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
712 ms |
4864 KB |
02.txt |
AC |
710 ms |
4992 KB |
03.txt |
AC |
177 ms |
1408 KB |
04.txt |
AC |
4 ms |
256 KB |
05.txt |
AC |
398 ms |
4864 KB |
06.txt |
AC |
349 ms |
4992 KB |
07.txt |
AC |
642 ms |
4864 KB |
08.txt |
AC |
662 ms |
4864 KB |
09.txt |
AC |
673 ms |
4992 KB |
10.txt |
AC |
4 ms |
256 KB |
11.txt |
AC |
729 ms |
4992 KB |
12.txt |
AC |
689 ms |
4864 KB |
13.txt |
AC |
6 ms |
256 KB |
14.txt |
AC |
789 ms |
4864 KB |
15.txt |
AC |
774 ms |
4864 KB |
empty.txt |
AC |
4 ms |
256 KB |
sample_01.txt |
AC |
4 ms |
256 KB |
sample_02.txt |
AC |
4 ms |
256 KB |
sample_03.txt |
AC |
4 ms |
256 KB |