Submission #1239879
Source Code Expand
import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long h=sc.nextInt(); long w=sc.nextInt(); int n=sc.nextInt(); HashSet<Long> hs1=new HashSet<>(); HashSet<Long> hs2=new HashSet<>(); for(int i=0;i<n;i++){ long a=sc.nextInt()-1; long b=sc.nextInt()-1; hs1.add(a*w+b); } long[] count=new long[10]; count[0]=(h-2)*(w-2); for(long l:hs1){ long a=l/w; long b=l%w; for(long i=a-1;i<=a+1;i++){ for(long j=b-1;j<=b+1;j++){ if(i>0 && i<h-1 && j>0 && j<w-1 && !hs2.contains(i*w+j)){ int temp=0; for(long ii=i-1;ii<=i+1;ii++){ for(long jj=j-1;jj<=j+1;jj++){ if(hs1.contains(ii*w+jj))temp++; } } count[temp]++; count[0]--; hs2.add(i*w+j); } } } } for(int i=0;i<10;i++)System.out.println(count[i]); } }
Submission Info
Submission Time | |
---|---|
Task | D - Snuke's Coloring |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 400 |
Code Size | 971 Byte |
Status | AC |
Exec Time | 1711 ms |
Memory | 213208 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 | 687 ms | 98300 KB |
02.txt | AC | 1290 ms | 211748 KB |
03.txt | AC | 439 ms | 56496 KB |
04.txt | AC | 95 ms | 19796 KB |
05.txt | AC | 856 ms | 99044 KB |
06.txt | AC | 697 ms | 98232 KB |
07.txt | AC | 1540 ms | 213208 KB |
08.txt | AC | 1634 ms | 209536 KB |
09.txt | AC | 1698 ms | 212728 KB |
10.txt | AC | 95 ms | 21972 KB |
11.txt | AC | 857 ms | 108112 KB |
12.txt | AC | 1711 ms | 155656 KB |
13.txt | AC | 144 ms | 22868 KB |
14.txt | AC | 1440 ms | 146920 KB |
15.txt | AC | 972 ms | 101728 KB |
empty.txt | AC | 94 ms | 20692 KB |
sample_01.txt | AC | 97 ms | 19668 KB |
sample_02.txt | AC | 108 ms | 21844 KB |
sample_03.txt | AC | 98 ms | 21204 KB |