結果

問題 No.455 冬の大三角
ユーザー 夜
提出日時 2020-10-15 11:27:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,378 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 91,576 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-28 01:09:18
合計ジャッジ時間 3,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,504 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,504 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,504 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 2 ms
4,380 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:42:5: 警告: ‘y2’ may be used uninitialized [-Wmaybe-uninitialized]
   42 |     if (y1 == y2) {
      |     ^~
main.cpp:25:21: 備考: ‘y2’ はここで定義されています
   25 |     int x1, y1, x2, y2;
      |                     ^~
main.cpp:50:10: 警告: ‘x2’ may be used uninitialized [-Wmaybe-uninitialized]
   50 |     else if (x1 == x2) {
      |          ^~
main.cpp:25:17: 備考: ‘x2’ はここで定義されています
   25 |     int x1, y1, x2, y2;
      |                 ^~
main.cpp:52:25: 警告: ‘y1’ may be used uninitialized [-Wmaybe-uninitialized]
   52 |             s[x1 + 1][y1] = '*';
      |                         ^
main.cpp:25:13: 備考: ‘y1’ はここで定義されています
   25 |     int x1, y1, x2, y2;
      |             ^~
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/string:53,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:42,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ostream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/iostream:39,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_data() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ 内,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/local/gcc7/include/c++/12.2.0/bits/basic_string.h:1224:16,
    inlined from ‘int main()’ at main.cpp:44:

ソースコード

diff #

#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