Skip to content

Commit a7cbbd3

Browse files
authored
Merge pull request #837 from AlgorithmWithGod/khj20006
[20250907] BOJ / P5 / 폭탄 던지는 태영이 / 권혁준
2 parents 79032b9 + f39e5bf commit a7cbbd3

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
```java
2+
import java.util.*;
3+
import java.io.*;
4+
5+
class IOController {
6+
BufferedReader br;
7+
BufferedWriter bw;
8+
StringTokenizer st;
9+
10+
public IOController() {
11+
br = new BufferedReader(new InputStreamReader(System.in));
12+
bw = new BufferedWriter(new OutputStreamWriter(System.out));
13+
st = new StringTokenizer("");
14+
}
15+
16+
String nextLine() throws Exception {
17+
String line = br.readLine();
18+
st = new StringTokenizer(line);
19+
return line;
20+
}
21+
22+
String nextToken() throws Exception {
23+
while (!st.hasMoreTokens()) nextLine();
24+
return st.nextToken();
25+
}
26+
27+
int nextInt() throws Exception {
28+
return Integer.parseInt(nextToken());
29+
}
30+
31+
long nextLong() throws Exception {
32+
return Long.parseLong(nextToken());
33+
}
34+
35+
double nextDouble() throws Exception {
36+
return Double.parseDouble(nextToken());
37+
}
38+
39+
void close() throws Exception {
40+
bw.flush();
41+
bw.close();
42+
}
43+
44+
void write(String content) throws Exception {
45+
bw.write(content);
46+
}
47+
48+
}
49+
50+
public class Main {
51+
52+
static IOController io;
53+
54+
//
55+
56+
static int N, M;
57+
static long[][] h, c, s;
58+
59+
public static void main(String[] args) throws Exception {
60+
61+
io = new IOController();
62+
63+
N = io.nextInt();
64+
M = io.nextInt();
65+
h = new long[N+1][N+1];
66+
c = new long[N+1][N+1];
67+
s = new long[N+1][N+1];
68+
for(int i=0;i<N;i++) for(int j=0;j<N;j++) h[i][j] = -io.nextLong();
69+
70+
for(int i=0;i+M<=N;i++) {
71+
for(int j=0;j+M<=N;j++) {
72+
long res = h[i][j] - c[i][j];
73+
s[i+M/2][j+M/2] = res;
74+
c[i+1][j] += h[i][j];
75+
c[i][j+1] += h[i][j];
76+
c[i+1][j+1] -= h[i][j];
77+
c[i+M][j] -= res;
78+
c[i][j+M] -= res;
79+
c[i+M][j+M] += res;
80+
}
81+
}
82+
83+
for(int i=0;i<N;i++) {
84+
for(int j=0;j<N;j++) io.write(s[i][j] + " ");
85+
io.write("\n");
86+
}
87+
88+
io.close();
89+
90+
}
91+
92+
}
93+
```

0 commit comments

Comments
 (0)