Submission #71667942
Source Code Expand
fun main() {
val cin = System.`in`.bufferedReader()
val cout = System.out.bufferedWriter()
var n = cin.readLine().toInt()
val ans = Array(n) { IntArray(n) }
var k = 1
var r = 0
var c = n/2
for (i in 0 until n*n) {
ans[r][c]=k++
if (ans[(r-1+n)%n][(c+1)%n]==0) {
r=(r-1+n)%n
c=(c+1)%n
} else {
r=(r+1)%n
}
}
for (i in 0 until n) {
cout.write("${ans[i].joinToString(separator = " ")}\n")
}
cout.flush()
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magic Square |
| User | jagbarrameda |
| Language | Kotlin (Kotlin/JVM 2.2.10) |
| Score | 200 |
| Code Size | 551 Byte |
| Status | AC |
| Exec Time | 86 ms |
| Memory | 44868 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 78 ms | 43736 KiB |
| 00_sample_01.txt | AC | 62 ms | 43712 KiB |
| 01_test_00.txt | AC | 63 ms | 43780 KiB |
| 01_test_01.txt | AC | 64 ms | 43780 KiB |
| 01_test_02.txt | AC | 63 ms | 43888 KiB |
| 01_test_03.txt | AC | 63 ms | 43704 KiB |
| 01_test_04.txt | AC | 77 ms | 44188 KiB |
| 01_test_05.txt | AC | 78 ms | 44480 KiB |
| 01_test_06.txt | AC | 81 ms | 44584 KiB |
| 01_test_07.txt | AC | 83 ms | 44672 KiB |
| 01_test_08.txt | AC | 86 ms | 44804 KiB |
| 01_test_09.txt | AC | 83 ms | 44824 KiB |
| 01_test_10.txt | AC | 85 ms | 44868 KiB |