結果

問題 No.455 冬の大三角
コンテスト
ユーザー miku39kk
提出日時 2017-08-09 17:32:50
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 784 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 477 ms
コンパイル使用メモリ 93,800 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-28 15:00:08
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:33: warning: ignoring return value of '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>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   23 |         else if(star == 1)s[0][0];
      |                                 ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:2:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1365:7: note: declared here
 1365 |       operator[](size_type __pos)
      |       ^~~~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h,"");
    for(int i = 0;i < h;i++){
        cin >> s[i];
    }
    int star = 0;
    for(int i = 0;i < w;i++)if(s[0][i] == '*')star++;
    if(star == 2)s[1][0] = '*';
    else if(star == 1)s[0][0] = '*';
    else{
        for(int i = 0;i < h;i++)if(s[i][0] == '*')star++;
        if(star == 2)s[0][1] = '*';
        else if(star == 1)s[0][0];
        else{
            for(int i = 0;i < w && i < h;i++)if(s[i][i] == '*')star++;
            if(star == 2)s[0][1] = '*';
            else s[0][0] = '*';
        }
    }
    for(int i = 0;i < h;i++){
        cout << s[i] << endl;
    }
    return 0;
}

0