結果

問題 No.1971 Easy Sudoku
ユーザー ripityripity
提出日時 2022-06-12 21:16:11
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 3,240 bytes
コンパイル時間 17,143 ms
コンパイル使用メモリ 455,608 KB
実行使用メモリ 54,376 KB
最終ジャッジ日時 2023-10-24 15:40:52
合計ジャッジ時間 23,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 285 ms
51,808 KB
testcase_01 AC 295 ms
51,876 KB
testcase_02 AC 352 ms
54,104 KB
testcase_03 AC 304 ms
53,988 KB
testcase_04 AC 379 ms
54,352 KB
testcase_05 AC 298 ms
51,880 KB
testcase_06 AC 295 ms
51,880 KB
testcase_07 AC 374 ms
54,376 KB
testcase_08 AC 294 ms
51,868 KB
testcase_09 AC 295 ms
51,884 KB
testcase_10 AC 308 ms
53,992 KB
testcase_11 AC 290 ms
51,808 KB
testcase_12 AC 284 ms
51,800 KB
testcase_13 AC 386 ms
54,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*
import java.util.*
import kotlin.math.*

fun main() {
    
    // val T = nextInt()
    // repeat(T) {solve()}
    // pw.flush()
    
    solve()
    pw.flush()
    
}

fun solve() {
    
    val N = nextInt()
    
    for( i in 0 until N ) {
        for( j in 0 until N ) {
            pw.print("${(i+j)%N+1} ")
        }
        pw.println()
    }
    
}

/* struct begin */

data class Cell(val r: Int, val c: Int)
data class Point(val x: Double, val y: Double)
data class Pii(val fi: Int, val se: Int)
data class Edge(val to: Int, val w: Long)

class BinaryIndexedTree(n: Int) {
    
    val N = n
    var a = Array<Long>(N+1) {0L}
    
    fun sum(i: Int): Long {
        
        var idx = i+1
        var res = 0L
        while( idx > 0 ) {
            res += a[idx]
            idx -= idx and (-idx)
        }
        
        return res
        
    }
    
    fun add(i: Int, x: Long) {
        
        var idx = i+1
        while( idx <= N ) {
            a[idx] += x
            idx += idx and (-idx)
        }
        
    }
    
}

class UnionFind(N: Int) {
    
    var parent = Array<Int>(N) {it}
    var rank = Array<Int>(N) {1}
    var size = Array<Int>(N) {1}
    
    fun root(x: Int): Int {
        
        if( parent[x] == x ) {
            return x
        }else {
            parent[x] = root(parent[x])
            return parent[x]
        }
        
    }
    
    fun unite(x: Int, y: Int) {
        
        val rx = root(x)
        val ry = root(y)
        if( rx == ry ) return
        
        if( rank[rx] > rank[ry] ) {
            parent[ry] = rx
            size[rx] += size[ry]
        }else {
            parent[rx] = ry
            size[ry] += size[rx]
            if( rank[rx] == rank[ry] ) rank[ry]++
        }
        
    }
    
    fun same(x: Int, y: Int): Boolean = (root(x) == root(y))
    fun getSize(x: Int): Int = size[root(x)]
    
}

/* struct end */

/* math begin */

fun intceil(x: Double) = ceil(x).toInt()
fun intfloor(x: Double) = floor(x).toInt()
fun gcd(x: Long, y: Long): Long {
    
    var a = max(abs(x), abs(y))
    var b = min(abs(x), abs(y))
    var r: Long
    
    do {
        r = a%b
        a = b
        b = r
    }while( r > 0 )
    
    return a
    
}

fun modpow(X: Long, T: Long, P: Long = 9223372036854775807L): Long {
    
    var x = X
    var t = T
    
    if( t == 0L ) {
        return 1L
    }else {
        var res = 1L
        while( t > 0 ) {
            if( t%2L == 1L ) {
                res *= x
                res %= P
                t -= 1L
            }
            x *= x
            x %= P
            t /= 2
        }
        return res%P
    }
    
}

/* math end */

/* I/O begin */

var st = StringTokenizer("")
val br = System.`in`.bufferedReader()
val pw = PrintWriter(System.out, false)

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()!!
fun nextDouble() = next().toDouble()
fun nextIntarr(n: Int) = IntArray(n) {nextInt()}
fun nextStrarr(n: Int) = Array<String>(n) {next()}
fun nextLongarr(n: Int) = LongArray(n) {nextLong()}

fun next(): String {
    
    if( !st.hasMoreTokens() ) st = StringTokenizer(br.readLine()!!)
    return st.nextToken()
    
}

/* I/O end */
0