fork download
  1. # -- read input --
  2. (x, X, y, Y) = map(int, raw_input().split())
  3. N = int(raw_input())
  4. xhash = {}
  5. for _ in range(N):
  6. (x1, x2, v) = map(int, raw_input().split())
  7. xhash[x1] = v
  8. xhash[x2] = 0
  9. # -- print chart --
  10. d_x, d_y = len(str(X)), len(str(Y))
  11. fmt = lambda x: '*'.rjust(d_x) if a <= xhash[x] else ' '.rjust(d_x)
  12. keys = sorted(xhash.keys())
  13. for a in range(Y, y-1, -1):
  14. print str(a).rjust(d_y), ' '.join(map(fmt, keys))
  15. print str('').rjust(d_y), ' '.join(map(lambda x: str(x).rjust(d_x), keys))
Success #stdin #stdout 0s 9032KB
stdin
0 50 1 10
5
0 10 1
10 20 3
20 30 6
30 40 4
40 50 2
stdout
10                  
 9                  
 8                  
 7                  
 6        *         
 5        *         
 4        *  *      
 3     *  *  *      
 2     *  *  *  *   
 1  *  *  *  *  *   
    0 10 20 30 40 50