結果

問題 No.509 塗りつぶしツール
ユーザー nukacha
提出日時 2017-04-30 01:55:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 331 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 61,344 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-30 22:56:50
合計ジャッジ時間 1,928 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:12: warning: ‘hs’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |         hs += h[(int)n[i] - (int)'0'];
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:7:9: note: ‘hs’ was declared here
    7 |     int hs;
      |         ^~

ソースコード

diff #

#include <iostream>
#include <string>

int main() {
    std::string n;
    int h[10] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1};
    int hs;
    int l;
    std::cin >> n;
    l = n.size();
    for (int i = 0; i < l; i++) {
        hs += h[(int)n[i] - (int)'0'];
    }
    std::cout << std::min(l * 2 + hs + 1, l + hs * 2 + 2) << std::endl;
}
0