結果

問題 No.656 ゴルフ
ユーザー cww
提出日時 2018-04-04 11:10:20
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 515 bytes
コンパイル時間 7,312 ms
コンパイル使用メモリ 243,200 KB
最終ジャッジ日時 2025-01-05 09:54:27
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/numeric:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:84,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h: In instantiation of 'constexpr _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation) [with _InputIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int; _BinaryOperation = main()::<lambda(int&, int&)>]':
main.cpp:17:23:   required from here
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h:169:29: error: no match for call to '(main()::<lambda(int&, int&)>) (std::remove_reference<int&>::type, int&)'
  169 |         __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h:169:29: note: candidate: 'int (*)(int&, int&)' (conversion)
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h:169:29: note:   conversion of argument 2 would be ill-formed:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h:169:29: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'std::remove_reference<int&>::type' {aka 'int'}
main.cpp:17:38: note: candidate: 'main()::<lambda(int&, int&)>' (near match)
   17 |     cout << accumulate( ALL( v ), 0, []( int &sum, int &x ){ return x != 0 ? sum += x : sum += 10; } ) << endl;
      |                                      ^
main.cpp:17:38: note:   conversion of argument 1 would be ill-formed:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_numeric.h:169:29: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'std::remove_reference<int&>::type' {aka 'int'}

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
const long long INF = numeric_limits<long long>::max();
// yukicoder は使いやすい
int main()
{
    string S;
    cin >> S;
    vector<int> v( 9 );
    REP( i, (int)S.size() )
    {
        v[ i ] = S[ i ] - '0';
    }
    cout << accumulate( ALL( v ), 0, []( int &sum, int &x ){ return x != 0 ? sum += x : sum += 10; } ) << endl;
    return 0;
}
0