From 3ef2f79a43c8d990083ddd1976457cc8867b54fc Mon Sep 17 00:00:00 2001 From: oncsr Date: Sat, 8 Mar 2025 21:28:40 +0900 Subject: [PATCH] =?UTF-8?q?[20250308]=20BOJ=20/=20G3=20/=20=EC=9D=B8?= =?UTF-8?q?=EC=A7=80=EC=9C=B5~=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \354\235\270\354\247\200\354\234\265~.md" | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 "khj20006/202503/08 BOJ G3 \354\235\270\354\247\200\354\234\265~.md" diff --git "a/khj20006/202503/08 BOJ G3 \354\235\270\354\247\200\354\234\265~.md" "b/khj20006/202503/08 BOJ G3 \354\235\270\354\247\200\354\234\265~.md" new file mode 100644 index 00000000..a4532783 --- /dev/null +++ "b/khj20006/202503/08 BOJ G3 \354\235\270\354\247\200\354\234\265~.md" @@ -0,0 +1,115 @@ +```java + +import java.util.*; +import java.io.*; + + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, C, E; + static char[][] A; + static int[] dx = {1,0,-1,0}; + static int[] dy = {0,1,0,-1}; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = Integer.parseInt(br.readLine()); + nextLine(); + C = nextInt(); + E = nextInt(); + A = new char[N][N]; + + } + + static void solve() throws Exception{ + + int G = 1; + for(int g=0;g=0;g--){ + if(E == 0) break; + int x=N-1, y=g; + for(int k=0;k<=N-1-g;k++){ + if(E == 0) break; + if(!safe(x,y)) { + bw.write("-1"); + return; + } + A[x--][y++] = '2'; + E--; + } + } + for(int g=N-2;g>=0;g--){ + if(E == 0) break; + int x=g, y=0; + for(int k=0;k<=g;k++){ + if(E == 0) break; + if(!safe(x,y)){ + bw.write("-1"); + return; + } + A[x--][y++] = '2'; + E--; + } + } + + bw.write("1\n"); + for(int i=0;i= '1' ? A[i][j] : '0')); + bw.write("\n"); + } + + } + + static boolean safe(int x, int y){ + for(int i=0;i<4;i++){ + int xx = x+dx[i], yy = y+dy[i]; + if(xx<0 || xx>=N || yy<0 || yy>=N) continue; + if(A[xx][yy] == '1') return false; + } + return true; + } + +} + +```