結果

問題 No.455 冬の大三角
ユーザー TangentDayTangentDay
提出日時 2016-12-08 01:10:07
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,211 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-29 21:24:15
合計ジャッジ時間 2,598 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:51:11: warning: ‘y2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |     }else if (y1 == y2){
      |           ^~
main.cpp:47:5: warning: ‘x2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     if (x1 == x2){
      |     ^~
main.cpp:53:9: warning: ‘y1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |         if (y1 == 0) y = 1;
      |         ^~
main.cpp:49:9: warning: ‘x1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |         if (x1 == 0) x = 1;
      |         ^~

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];
    int x1, y1, x2, y2;
    int f = 0;
    REP(i,h) REP(j,w){
        if (s[i][j] == '*'){
            if (f == 0){
                x1 = i;
                y1 = j;
                f = 1;
            }else{
                x2 = i;
                y2 = j;
            }
        }
    }
    int x, y;
    if (x1 == x2){
        y = y1;
        if (x1 == 0) x = 1;
        else x = 0;
    }else if (y1 == y2){
        x = x1;
        if (y1 == 0) y = 1;
        else y = 0;
    }else{
        x = x1;
        y = y2;
    }
    s[x][y] = '*';
    REP(i,h) cout << s[i] << endl;
    return 0;
}
0