結果

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))


double TreePointTriangle(double ax, double ay, double bx, double by, double cx, double cy){
    return 0.5*abs(ax*(by-cy)+bx*(cy-ay)+cx*(ay-by));
}


int main(){
    
    int H,W; cin>>H>>W;
    vector<string> S(H);
    REP(i,H)cin>>S[i];
    
    vector<string> ans=S;
    
    double ax=-1,ay=-1;
    double bx=-1,by=-1;
    REP(i,H)REP(j,W){
        if(S[i][j]=='*'){
            ax=j;
            ay=i;
            S[i][j]='-';
            goto next1;
        }
    }
    
next1:;
    
    REP(i,H)REP(j,W){
        if(S[i][j]=='*'){
            bx=j;
            by=i;
            goto next2;
        }
    }
    
next2:;
    
    REP(i,H)REP(j,W){
        double cx=j,cy=i;
        double area=TreePointTriangle(ax,ay,bx,by,cx,cy);
        if(area>0){
            ans[i][j]='*';
            REP(i,H)cout<<ans[i]<<endl;
            return 0;
        }
    }
    
    return 0;
}
0