Submission #1688620
Source Code Expand
#include<bits/stdc++.h>
// Shrotening
#define fst first
#define snd second
#define pb push_back
// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)
#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)
#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)
//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))
#define UNIQUE(a) SORT(a), a.erase(std::unique(ALL(a)), a.end());
//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);
//debug message
bool debug = true;
#define MSG(s) if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}
//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector< VC > VCC;
typedef std::vector<int> VI;
typedef std::vector< VI > VII;
typedef std::vector<long> VL;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;
LL H, W, N;
std::set< PII > AB;
std::set< PII > looked;
VLL cnt(10,0);
int main() {
std::cin >> H >> W >> N;
REP(i, N) {
PII p;
std::cin >> p.snd >> p.fst;
p.fst--;
p.snd--;
AB.insert(p);
}
EACH(it, AB) {
int x = it->fst, y = it->snd;
FOR(i, -1, 2) {
FOR(j, -1, 2) {
int cx = x + i;
int cy = y + j;
if(looked.count(std::make_pair(cx,cy)) > 0) {
continue;
}
if(cx < 1 || cy < 1 || cx >= W-1 || cy >= H-1){
continue;
}
looked.insert(std::make_pair(cx,cy));
int ans = 0;
FOR(dx, -1, 2) {
FOR(dy, -1, 2) {
int nx = cx + dx;
int ny = cy + dy;
if(AB.count(std::make_pair(nx,ny)) > 0) {
ans++;
}
}
}
cnt[ans]++;
}
}
}
cnt[0] = (H-2)*(W-2) - std::accumulate(ALL(cnt), 0);
REP(i, 10) {
std::cout << cnt[i] << std::endl;
}
}
Submission Info
Submission Time |
|
Task |
D - Snuke's Coloring |
User |
b1464296 |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2479 Byte |
Status |
AC |
Exec Time |
991 ms |
Memory |
47104 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, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
316 ms |
9472 KB |
02.txt |
AC |
562 ms |
35584 KB |
03.txt |
AC |
66 ms |
3712 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
536 ms |
18944 KB |
06.txt |
AC |
457 ms |
18944 KB |
07.txt |
AC |
791 ms |
47104 KB |
08.txt |
AC |
991 ms |
47104 KB |
09.txt |
AC |
915 ms |
47104 KB |
10.txt |
AC |
1 ms |
256 KB |
11.txt |
AC |
564 ms |
33664 KB |
12.txt |
AC |
689 ms |
46976 KB |
13.txt |
AC |
2 ms |
256 KB |
14.txt |
AC |
634 ms |
39680 KB |
15.txt |
AC |
590 ms |
33664 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 |