제출 #1230299

#제출 시각아이디문제언어결과실행 시간메모리
1230299amawTrol (COCI19_trol)C++20
10 / 50
1096 ms580 KiB
#include <iostream>
#include <algorithm>
using namespace std;

int memo[32767];

unsigned int jumlah(int n) {
    if (n < 10) return n;
    int temp = n % 10 + jumlah(n / 10);
    memo[n] = temp;
    if (temp < 10) return temp;
    else {
        if (memo[temp] != -1) return memo[temp];
        else return temp % 10 + jumlah(temp / 10);
    }
}

int main() {
    int q;
    cin >> q;
    
    int R[q]; int L[q];
    for (int i = 0; i < q; i++) {
        cin >> R[i] >> L[i];
    }
    
    fill(memo, memo + 32768, -1);
    
    int hasil[q] = {0};
    for (int i = 0; i < q; i++) {
        int min = R[i]; int maks = L[i];
        
        for (int j = min; j <= maks; j++) {
            hasil[i] += jumlah(j);
        }
        
    }
    
    for (int i = 0; i < q; i++) {
        cout << hasil[i] << endl; 
    }
}

컴파일 시 표준 에러 (stderr) 메시지

In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from trol.cpp:1:
In function 'constexpr typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]',
    inlined from 'constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int*; _Tp = int]' at /usr/include/c++/11/bits/stl_algobase.h:969:21,
    inlined from 'constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]' at /usr/include/c++/11/bits/stl_algobase.h:999:20,
    inlined from 'int main()' at trol.cpp:27:9:
/usr/include/c++/11/bits/stl_algobase.h:924:18: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 131072 bytes into a region of size 131068 overflows the destination [-Wstringop-overflow=]
  924 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
trol.cpp: In function 'int main()':
trol.cpp:5:5: note: destination object 'memo' of size 131068
    5 | int memo[32767];
      |     ^~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from trol.cpp:1:
In function 'constexpr typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]',
    inlined from 'constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int*; _Tp = int]' at /usr/include/c++/11/bits/stl_algobase.h:969:21,
    inlined from 'constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]' at /usr/include/c++/11/bits/stl_algobase.h:999:20,
    inlined from 'int main()' at trol.cpp:27:9:
/usr/include/c++/11/bits/stl_algobase.h:924:18: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 131072 bytes into a region of size 131068 overflows the destination [-Wstringop-overflow=]
  924 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
trol.cpp: In function 'int main()':
trol.cpp:5:5: note: destination object 'memo' of size 131068
    5 | int memo[32767];
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...