結果

問題 No.455 冬の大三角
ユーザー 0w10w1
提出日時 2016-12-07 11:36:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,720 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 172,364 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 08:32:29
合計ジャッジ時間 4,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef pair< int, int > pii;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector< pii > vp;
typedef vector< vp > vvp;
typedef vector< string > vs;
typedef vector< double > vd;
typedef vector< vd > vvd;

template< class T1, class T2 >
int upmin( T1 &x, T2 v ){
  if( x > v ){
    x = v;
    return 1;
  }
  return 0;
}

template< class T1, class T2 >
int upmax( T1 &x, T2 v ){
  if( x < v ){
    x = v;
    return 1;
  }
  return 0;
}

const int INF = 0x3f3f3f3f;

int H, W;
vs G;

void init(){
  cin >> H >> W;
  G = vs( H );
  for( int i = 0; i < H; ++i )
    cin  >> G[ i ];
}

vp pnt;

void preprocess(){
  for( int i = 0; i < H; ++i )
    for( int j = 0; j < W; ++j )
      if( G[ i ][ j ] == '*' )
        pnt.emplace_back( i, j );
}

int ok( pii a, pii b, pii c ){
  int dx1 = b.first - a.first;
  int dy1 = b.second - a.second;
  int dx2 = c.first - b.first;
  int dy2 = c.second - b.second;
  int g1 = __gcd( dx1, dy1 );
  int g2 = __gcd( dx2, dy2 );
  dx1 /= g1, dy1 /= g1;
  if( dx1 < 0 ) dx1 *= -1, dy1 *= -1;
  dx2 /= g2, dy2 /= g2;
  if( dx2 < 0 ) dx2 *= -1, dy2 *= -1;
  return not ( dx1 == dx2 and dy1 == dy2 );
}

void solve(){
  for( int i = 0; i < H; ++i )
    for( int j = 0; j < W; ++j )
      if( G[ i ][ j ] != '*' )
        if( ok( pnt[ 0 ], pnt[ 1 ], make_pair( i, j ) ) ){
          G[ i ][ j ] = '*';
          for( int x = 0; x < H; ++x, cout << endl )
            for( int y = 0; y < W; ++y )
              cout << G[ x ][ y ];
          exit( 0 );
        }
}

signed main(){
  ios::sync_with_stdio( 0 );
  init();
  preprocess();
  solve();
  return 0;
}
0