BOJ::문제풀이
2563 색종이
2영재
2018. 1. 1. 21:28
BOJ::2563 색종이
https://www.acmicpc.net/problem/2563
아주아주 쉬운 문제 인데 생각보다 엄청 오래걸려서 포스팅해본다.
<JAVA>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String args[]) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine().trim()); int map[][]=new int[100][100]; StringTokenizer st = null; int cnt=0; for(int i = 0 ; i < n ; i++){ st = new StringTokenizer(br.readLine()); int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken()); for(int j = x ; j <x+10 ; j++){ for(int k = y; k<y+10 ; k++){ if(x<100&&y<100){ if(map[j][k]==1){ continue; } map[j][k]=1; cnt++; } } } } System.out.println(cnt); } } | cs |