fork download
  1. fun main(args: Array<String>) {
  2. if(args.isNotEmpty()) {
  3. System.setIn(java.io.FileInputStream(args[0]))
  4. }
  5.  
  6. fun solve(N: Int, K: Int): String {
  7. if(K > N) return "(".repeat(N/2) + ")".repeat(N/2)
  8. if(K == N || K <= 4) return "-1"
  9. return "(".repeat((N-K-2)/2) + ("(())" + "(".repeat((K-2)/2) + ")".repeat((K-2)/2)) + ")".repeat((N-K-2)/2)
  10. }
  11.  
  12. val numTests = readLine()!!.toInt()
  13. require(numTests in 1..1000)
  14.  
  15. var sumN = 0
  16. repeat(numTests) {
  17. val (N, K) = readLine()!!.split(" ").map{ it.toInt() }
  18. require(N in 2..100000)
  19. require(K in 2..100000)
  20. sumN += N
  21. require(sumN <= 100000)
  22. require(N % 2 == 0)
  23. require(K % 2 == 0)
  24.  
  25. println(solve(N, K))
  26. }
  27.  
  28. require(readLine() == null)
  29. }
Runtime error #stdin #stdout #stderr 0.12s 34060KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" kotlin.KotlinNullPointerException
	at ProgKt.main(prog.kt:12)