結果
| 問題 | No.678 2Dシューティングゲームの必殺ビーム | 
| コンテスト | |
| ユーザー |  tsuchinaga | 
| 提出日時 | 2019-03-23 19:03:54 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 910 bytes | 
| コンパイル時間 | 11,764 ms | 
| コンパイル使用メモリ | 233,504 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-24 08:56:27 | 
| 合計ジャッジ時間 | 11,921 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 | 
ソースコード
package main
import (
	"fmt"
	"math"
	"sort"
)
func main() {
	var n, xlb, xrb int // 敵の数, ビームの左端, ビームの右端
	_, _ = fmt.Scan(&n, &xlb, &xrb)
	type unit struct {
		i, xl, yu, xr, yd int
	}
	units := make([]unit, n)
	for i := range units {
		units[i].i = i
		_, _ = fmt.Scan(&units[i].xl, &units[i].yu, &units[i].xr, &units[i].yd)
	}
	// fmt.Println(units)
	sort.Slice(units, func(i, j int) bool {
		return units[i].xl < units[j].xl || (units[i].xl == units[j].xl && units[i].yu < units[j].yu)
	})
	// fmt.Println(units)
	hits := make(map[int]int, n)
	for i := xlb; i <= xrb; i++ {
		hit := -1
		hitY := math.MinInt64
		for _, u := range units {
			if u.xl <= i && i <= u.xr {
				if hitY < u.yu {
					hitY = u.yu
					hit = u.i
				}
			}
		}
		if hit >= 0 {
			hits[hit] = hits[hit] | 1
		}
		// fmt.Println(i, hits)
	}
	for i := 0; i < n; i++ {
		fmt.Println(hits[i])
	}
}
            
            
            
        