結果

問題 No.455 冬の大三角
ユーザー mayoko_mayoko_
提出日時 2016-12-07 16:19:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 75,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-29 21:19:59
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<utility>
#include<vector>

using namespace std;
vector<pair<int, int> > stars;
vector<string> board;
int H, W;

bool check(int x, int y) {
    int dx0 = x-stars[0].first, dy0 = y-stars[0].second;
    int dx1 = x-stars[1].first, dy1 = y-stars[1].second;
    if (dx0 == 0 && dy0 == 0) return false;
    if (dx1 == 0 && dy1 == 0) return false;
    if (dx0*dy1 == dx1*dy0) return false;
    return true;
}

int main() {
    cin >> H >> W;
    board.resize(H);
    for (int i = 0; i < H; i++) {
        cin >> board[i];
        for (int j = 0; j < W; j++) {
            if (board[i][j] == '*') stars.emplace_back(j, i);
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (check(j, i)) {
                board[i][j] = '*';
                for (int y = 0; y < H; y++) {
                    cout << board[y] << endl;
                }
                return 0;
            }
        }
    }
    return 0;
}
0