結果
問題 | No.455 冬の大三角 |
ユーザー | mamekin |
提出日時 | 2016-12-14 20:18:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,076 bytes |
コンパイル時間 | 1,015 ms |
コンパイル使用メモリ | 105,576 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-29 21:39:16 |
合計ジャッジ時間 | 2,598 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; class Point { public: int y, x; Point(){ y = x = 0; } Point(int y0, int x0){ y = y0; x = x0; } Point operator+(const Point& p) const{ return Point(y + p.y, x + p.x); } Point operator-(const Point& p) const{ return Point(y - p.y, x - p.x); } Point operator*(int a) const{ return Point(y * a, x * a); } bool operator==(const Point& p) const{ return y == p.y && x == p.x; } long long length2() const{ return y * (long long)y + x * (long long)x; } long long dist2(const Point& p) const{ return (y - p.y) * (long long)(y - p.y) + (x - p.x) * (long long)(x - p.x); } long long dot(const Point& p) const{ return y * (long long)p.y + x * (long long)p.x; // |a|*|b|*cosθ } long long cross(const Point& p) const{ return x * (long long)p.y - y * (long long)p.x; // |a|*|b|*sinθ } }; void solve(vector<string>& s) { int h = s.size(); int w = s[0].size(); vector<Point> v; for(int y=0; y<h; ++y){ for(int x=0; x<w; ++x){ if(s[y][x] == '*') v.push_back(Point(y, x)); } } for(int y=0; ; ++y){ for(int x=0; x<w; ++x){ Point p(y, x); if((v[0] - p).cross(v[1] - p) != 0){ s[y][x] = '*'; return; } } } } int main() { int h, w; cin >> h >> w; vector<string> s(h); for(int i=0; i<h; ++i) cin >> s[i]; solve(s); for(int i=0; i<h; ++i) cout << s[i] << endl; return 0; }