Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. import com.sun.xml.internal.fastinfoset.util.StringArray
  2. import java.io.*
  3. import java.util.*
  4. import java.lang.Math.*
  5. import java.sql.Struct
  6.  
  7. fun solve(io: FastIO) {
  8.     var n = io.nextInt()
  9.     var m = io.nextInt()
  10.     var s = Array<String>(m, { "a" })
  11.     var g = 0
  12.     for (i in 0 until m) {
  13.         s[i] = io.nextLine()
  14.     }
  15.     for (i in 0 until n) {
  16.         for (j in 0 until n) {
  17.             if (i == j) io.print(""+0+" ")
  18.             else if (i != j) {
  19.                 for (h in 0 until m) {
  20.                     if (s[h] == (i+1).toString() + " " + (j+1).toString() || s[h] == (j+1).toString() + " " + (i+1).toString()) {
  21.                         g = 1
  22.                     }
  23.                 }
  24.                 if (g == 1) io.print(""+1+" ")
  25.                 else io.print(""+0+" ")
  26.             }
  27.         }
  28. io.println()
  29.     }
  30. }
  31.  
  32.  
  33. fun main(args: Array<String>) {
  34.     FastIO(System.`in`, System.out).use {
  35.         solve(it)
  36.     }
  37. }
  38.  
  39. class FastIO(inp: InputStream, out: OutputStream) : PrintWriter(out) {
  40.     private val reader = BufferedReader(InputStreamReader(inp))
  41.     private var tokenizer = StringTokenizer("")
  42.  
  43.     fun nextToken(): String? {
  44.         while (!tokenizer.hasMoreTokens()) {
  45.             val s = reader.readLine() ?: return null
  46.             tokenizer = StringTokenizer(s)
  47.         }
  48.  
  49.         return tokenizer.nextToken()
  50.     }
  51.     fun nextInt() = nextToken()!!.toInt()
  52.     fun nextLong() = nextToken()!!.toLong()
  53.     fun nextDouble() = nextToken()!!.toDouble()
  54.     fun nextWord() = nextToken()!!
  55.     fun nextLine() = reader.readLine()
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement