結果

問題 No.455 冬の大三角
ユーザー olphe
提出日時 2016-12-06 13:42:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 66,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 21:15:32
合計ジャッジ時間 2,717 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "iomanip"
#include "math.h"
using namespace std;

int W, H;
char star[1000][1000];
bool flag[1000][1000];
int x[2];
int y[2];
int ans_x;
int ans_y;
int num;

int main() {
	cin >> H >> W;
	num = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> star[i][j];
			if (star[i][j] == '*') {
				flag[i][j] = true;
				x[num] = j;
				y[num] = i;
				num++;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (!flag[i][j]) {
				if ((i != y[0] || i != y[1] || y[0] != y[1]) && (j != x[0] || j != x[1] || x[0] != x[1]) && ((double)y[0] - i) / ((double)y[1] - i) != ((double)x[0] - j) / ((double)x[1] - j)) {
					ans_x = j;
					ans_y = i;
				}
			}
		}
	}
	flag[ans_y][ans_x] = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (flag[i][j])cout << "*";
			else cout << "-";
		}
		cout << "\n";
	}
	return 0;
}
0