public static void Main(string[] args) { using (var helper = new CodeJamHelper('D', ProblemType.Large)) { Omino.Run(helper); } }
public Omino Clone() { var clone = new Omino(); clone.Points = this.Points.ToList(); clone.Normalize(); return(clone); }
public void Play() { playing = true; if (level != null) { omino = level.GetComponentInChildren <Omino>(); omino.enabled = true; } }
public void Pause() { playing = false; testPlaying = false; if (level != null) { omino = level.GetComponentInChildren <Omino>(); omino.enabled = false; } }
static IEnumerable <Omino> GetOmino(int N) { Omino init = new Omino(); init.Points.Add(new Point(0, 0)); init.Normalize(); Queue <Omino> queue = new Queue <Omino>(); queue.Enqueue(init); Dictionary <string, Omino> memo = new Dictionary <string, Omino>(); while (queue.Count > 0) { var now = queue.Dequeue(); var id = now.GetId(); if (memo.ContainsKey(id)) { continue; } memo[id] = now; if (now.Points.Count >= N) { continue; } foreach (var p in now.Points) { for (int i = 0; i < 4; i++) { int nr = p.Row + dy[i]; int nc = p.Col + dx[i]; if (!now.Points.Any(q => q.Row == nr && q.Col == nc)) { var next = now.Clone(); next.Points.Add(new Point(nr, nc)); queue.Enqueue(next); } } } } return(memo.Values.Where(v => v.Points.Count == N).ToArray()); }
static bool Check(Omino omino, int R, int C, int X) { var width = omino.Width; var height = omino.Height; if (width > C) { return(false); } if (height > R) { return(false); } //if (width + 2 <= C && height + 2 <= R) return true; for (int i = 0; i + height - 1 < R; i++) { for (int j = 0; j + width - 1 < C; j++) { var table = new bool[R, C]; foreach (var p in omino.Points) { table[p.Row + i, p.Col + j] = true; } bool ok = true; for (int p = 0; p < R && ok; p++) { for (int q = 0; q < C && ok; q++) { if (!table[p, q]) { var cnt = FloodFill(table, p, q); if (cnt % X != 0) { ok = false; break; } } } } if (ok) { return(true); } } } return(false); }
bool Check(Omino o, int n, int r, int c) { if (o.Height > r || o.Width > c) { return(false); } for (int i = 0; i + o.Height <= r; i++) { for (int j = 0; j + o.Width <= c; j++) { var f = new bool[r, c]; for (int ii = 0; ii < o.Height; ii++) { for (int jj = 0; jj < o.Width; jj++) { if (o.F[ii, jj]) { f[i + ii, j + jj] = true; } } } bool ok = true; for (int ii = 0; ok && ii < r; ii++) { for (int jj = 0; ok && jj < c; jj++) { if (Dfs(f, ii, jj, r, c) % n > 0) { ok = false; } } } if (ok) { return(true); } } } return(false); }