結果
問題 | No.455 冬の大三角 |
ユーザー |
![]() |
提出日時 | 2017-01-05 00:13:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 73,200 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 22:14:02 |
合計ジャッジ時間 | 2,382 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
#include<iostream> #include<vector> #include<cmath> using namespace std; bool check(int x1, int y1, int x2, int y2, int x, int y){ if( (x==x1 && y==y1) || (x==x2 && y==y2) || (x1==x2 && x1==x) || (y1==y2 && y1==y) ) return false; else if( ( (double)(y1-y2)/(x1-x2) == (double)(y1-y)/(x1-x)) || ( (double)(y1-y2)/(x1-x2) == (double)(-y1+y)/(x1-x)) ) return false; else return true; } int main(){ int H,W; cin >> H >> W; vector< string > S; vector< vector<int> > X; vector<int> sol; for(int i=0; i<H ; i++){ string s; cin >> s; S.push_back(s); } for(int i=0; i<H ; i++){ for(int j=0; j<W; j++){ if(S[i][j]=='*'){ vector<int> x{i,j}; X.push_back(x); } } } for(int i=0; i<H; i++) for(int j=0; j<W; j++) if(check(X[0][0],X[0][1],X[1][0],X[1][1],i,j)){ sol.push_back(i); sol.push_back(j); break; } for(int i=0; i<H ; i++){ for(int j=0 ; j<W; j++){ if(i==sol[0] && j==sol[1]) cout << "*"; else cout << S[i][j]; } cout << endl; } return 0; }