結果
問題 | No.455 冬の大三角 |
ユーザー |
![]() |
提出日時 | 2016-12-08 02:44:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,589 bytes |
コンパイル時間 | 726 ms |
コンパイル使用メモリ | 85,444 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 21:24:45 |
合計ジャッジ時間 | 2,583 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
/* -*- coding: utf-8 -*-** 455.cc: No.455 冬の大三角 - yukicoder*/#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<iostream>#include<string>#include<vector>#include<map>#include<set>#include<stack>#include<list>#include<queue>#include<deque>#include<algorithm>#include<numeric>#include<utility>#include<complex>#include<functional>using namespace std;/* constant */const int MAX_H = 100;const int MAX_W = 100;/* typedef */template <typename T>struct Pt {T x, y;Pt() {}Pt(T _x, T _y) : x(_x), y(_y) {}Pt(const Pt& pt) : x(pt.x), y(pt.y) {}bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }Pt<T> operator-() const { return Pt<T>(-x, -y); }Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }T dot(Pt v) const { return x * v.x + y * v.y; }T cross(Pt v) const { return x * v.y - y * v.x; }};typedef Pt<int> pt;/* global variables */string bds[MAX_H];pt ps[3];/* subroutines *//* main */int main() {int h, w;cin >> h >> w;for (int y = 0, k = 0; y < h; y++) {cin >> bds[y];for (int x = 0; x < w; x++)if (bds[y][x] == '*') ps[k++] = pt(x, y);}bool ok = false;for (int y = 0; ! ok && y < h; y++)for (int x = 0; ! ok && x < w; x++) {pt p(x, y), v0(p - ps[0]), v1(p - ps[1]);if (v0.cross(v1) != 0) {bds[y][x] = '*';ok = true;}}for (int y = 0; y < h; y++) cout << bds[y] << endl;return 0;}