結果
問題 | No.455 冬の大三角 |
ユーザー |
|
提出日時 | 2017-12-05 16:49:58 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 833 bytes |
コンパイル時間 | 860 ms |
コンパイル使用メモリ | 100,608 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 22:47:33 |
合計ジャッジ時間 | 3,090 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;void main(){auto rd = readln.split.to!(int[]), h = rd[0], w = rd[1];auto s = new char[][](h);foreach (i; 0..h) s[i] = readln.chomp.dup;int x1 = -1, y1 = -1, x2 = -1, y2 = -1;foreach (i; 0..h)foreach (j; 0..w)if (s[i][j] == '*') {if (x1 < 0 && y1 < 0) {x1 = j;y1 = i;} else {x2 = j;y2 = i;}}auto onLine(int x3, int y3){auto x12 = x2 - x1, y12 = y2 - y1;auto x13 = x3 - x1, y13 = y3 - y1;return x12 * y13 - x13 * y12 == 0;}loop: foreach (i; 0..h)foreach (j; 0..w) {if (s[i][j] == '*') continue;if (!onLine(j, i)) {s[i][j] = '*';break loop;}}foreach (i; 0..h)writeln(s[i]);}