結果

問題 No.455 冬の大三角
コンテスト
ユーザー
提出日時 2020-10-15 11:27:23
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,378 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 888 ms
コンパイル使用メモリ 110,288 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-03 02:15:38
合計ジャッジ時間 3,688 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:50:10: warning: 'x1' may be used uninitialized [-Wmaybe-uninitialized]
   50 |     else if (x1 == x2) {
      |          ^~
main.cpp:25:9: note: 'x1' was declared here
   25 |     int x1, y1, x2, y2;
      |         ^~
main.cpp:42:5: warning: 'y1' may be used uninitialized [-Wmaybe-uninitialized]
   42 |     if (y1 == y2) {
      |     ^~
main.cpp:25:13: note: 'y1' was declared here
   25 |     int x1, y1, x2, y2;
      |             ^~
main.cpp:50:10: warning: 'x2' may be used uninitialized [-Wmaybe-uninitialized]
   50 |     else if (x1 == x2) {
      |          ^~
main.cpp:25:17: note: 'x2' was declared here
   25 |     int x1, y1, x2, y2;
      |                 ^~
main.cpp:42:5: warning: 'y2' may be used uninitialized [-Wmaybe-uninitialized]
   42 |     if (y1 == y2) {
      |     ^~
main.cpp:25:21: note: 'y2' was declared here
   25 |     int x1, y1, x2, y2;
      |                     ^~

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[110];
int main() {
    int h, w;
    cin >> h >> w;
    bool b = false;
    int x1, y1, x2, y2;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '*') {
                if (!b) {
                    x1 = i;
                    y1 = j;
                    b = true;
                }
                else {
                    x2 = i;
                    y2 = j;
                }
            }
        }
    }
    if (y1 == y2) {
        if (y1 != w - 1) {
            s[x1][y1 + 1] = '*';
        }
        else {
            s[x1][y1 - 1] = '*';
        }
    }
    else if (x1 == x2) {
        if (x1 != h - 1) {
            s[x1 + 1][y1] = '*';
        }
        else {
            s[x1 - 1][y1] = '*';
        }
    }
    else{
        if (x1 != h - 1) {
            s[x1 + 1][y1] = '*';
        }
        else {
            s[x1 - 1][y1] = '*';
        }
    }
    for (int i = 0; i < h; i++) {
        cout << s[i] << endl;
    }
    return 0;
}
0