Submission #1239873
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 | 0 |
Code Size | 975 Byte |
Status | WA |
Exec Time | 1052 ms |
Memory | 143660 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 676 ms | 94788 KB |
02.txt | WA | 821 ms | 128604 KB |
03.txt | WA | 414 ms | 46932 KB |
04.txt | AC | 93 ms | 21972 KB |
05.txt | WA | 820 ms | 108280 KB |
06.txt | WA | 737 ms | 97268 KB |
07.txt | WA | 904 ms | 138796 KB |
08.txt | WA | 984 ms | 143660 KB |
09.txt | WA | 1052 ms | 140636 KB |
10.txt | WA | 95 ms | 19284 KB |
11.txt | WA | 767 ms | 96304 KB |
12.txt | WA | 965 ms | 129296 KB |
13.txt | WA | 127 ms | 23124 KB |
14.txt | WA | 827 ms | 109528 KB |
15.txt | WA | 924 ms | 107732 KB |
empty.txt | AC | 92 ms | 21716 KB |
sample_01.txt | AC | 92 ms | 23892 KB |
sample_02.txt | WA | 97 ms | 21588 KB |
sample_03.txt | AC | 91 ms | 21844 KB |