結果

問題 No.455 冬の大三角
ユーザー cormoran
提出日時 2016-12-06 17:38:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,791 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 172,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 21:15:50
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int H, W; cin >> H >> W;
        vector<string> G(H); cin >> G;
        vector<int> xs, ys;
        rep(y, H) rep(x, W) {
            if(G[y][x] == '*') {
                ys.push_back(y);
                xs.push_back(x);                
            }
        }
        assert(xs.size() == 2);
        int vx = xs[1] - xs[0];
        int vy = ys[1] - ys[0];
        rep(y, H) rep(x, W) {
            int ax = x - xs[0];
            int ay = y - ys[0];
            int cross = ax * vy - vx * ay;
            if(cross != 0) {
                G[y][x] = '*';
                goto OK;
            }
        }
        assert(0);
  OK:
        rep(y, H) cout << G[y] << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0