Submission #1119313

#TimeUsernameProblemLanguageResultExecution timeMemory
1119313MateiKing80Sum Zero (RMI20_sumzero)C++14
Compilation error
0 ms0 KiB
#pragma GCC optimize("Osize")
#include <bits/stdc++.h>

using namespace std;

const int N = 4e5;

int tata[N + 5], ptr[N + 5], a[N + 5];

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> a[i], a[i] += a[i - 1];
    map<int, int> mp;
    int last = n + 1;
    mp[a[n]] = n;
    a[n + 2] = -1;
    a[n + 1] = 0;
    tata[n + 1] = n + 2;
    tata[n + 2] = n + 2;
    for(int i = n; i; i --)
    {
        if(mp[a[i - 1]] != 0)
            last = min(last, mp[a[i - 1]]);
        mp[a[i - 1]] = i - 1;
        tata[i] = last + 1;
        a[i] = 1 + a[last + 1];
    }
    int q;
    cin >> q;
    for(int i = n + 2; i; i --)
    {
        if(a[ptr[ptr[tata[i]]]] - a[ptr[tata[i]]] == a[ptr[tata[i]]] - a[tata[i]])
            ptr[i] = ptr[ptr[tata[i]]];
        else
            ptr[i] = tata[i];
        assert(i == n + 2 || tata[i] > i);
        assert(i == n + 2 || ptr[i] > i);
    }
    for(int i = 1; i <= q; i ++)
    {
        int l, r, li;
        cin >> l >> r;
        li = l;
        r ++;
        while(1)
        {
            if(ptr[l] <= r)
                l = ptr[l];
            else if(tata[l] <= r)
                l = tata[l];
            else
                break;
        }
        cout << a[li] - a[l] << '\n';
    }
}

Compilation message (stderr)

sumzero.cpp:1:29: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
    1 | #pragma GCC optimize("Osize")
      |                             ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from sumzero.cpp:2:
/usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   71 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   76 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   82 |      __THROW __attribute__ ((__noreturn__));
      |                                           ^
/usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/c++/10/cctype:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:35,
                 from sumzero.cpp:2:
/usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   80 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   82 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   84 |      __THROW __attribute__ ((__const__));
      |                                        ^
/usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from sumzero.cpp:2:
/usr/include/ctype.h:108:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  108 | __exctype (isalnum);
      | ^~~~~~~~~
/usr/include/ctype.h:108:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:109:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  109 | __exctype (isalpha);
      | ^~~~~~~~~
/usr/include/ctype.h:109:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  110 | __exctype (iscntrl);
      | ^~~~~~~~~
/usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  111 | __exctype (isdigit);
      | ^~~~~~~~~
/usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  112 | __exctype (islower);
      | ^~~~~~~~~
/usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  113 | __exctype (isgraph);
      | ^~~~~~~~~
/usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  114 | __exctype (isprint);
      | ^~~~~~~~~
/usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  115 | __exctype (ispunct);
      | ^~~~~~~~~
/usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  116 | __exctype (isspace);
      | ^~~~~~~~~
/usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  117 | __exctype (isupper);
      | ^~~~~~~~~
/usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  118 | __exctype (isxdigit);
      | ^~~~~~~~~
/usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:122:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  122 | extern int tolower (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:122:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:125:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  125 | extern int toupper (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:125:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:130:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  130 | __exctype (isblank);
      | ^~~~~~~~~
/usr/include/ctype.h:130:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:135:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  135 | extern int isctype (int __c, int __mask) __THROW;
      |                                          ^~~~~~~
/usr/include/ctype.h:135:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:142:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  142 | extern int isascii (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:142:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:146:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  146 | extern int toascii (int __c) __THROW;
      |                              ^~~~~~~
/usr/include/ctype.h:146:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:150:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  150 | __exctype (_toupper);
      | ^~~~~~~~~
/usr/include/ctype.h:150:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:151:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  151 | __exctype (_tolower);
      | ^~~~~~~~~
/usr/include/ctype.h:151:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:251:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  251 | __exctype_l (isalnum_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:251:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:252:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  252 | __exctype_l (isalpha_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:252:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:253:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  253 | __exctype_l (iscntrl_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:253:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:254:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  254 | __exctype_l (isdigit_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:254:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:255:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  255 | __exctype_l (islower_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:255:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:256:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  256 | __exctype_l (isgraph_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:256:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:257:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  257 | __exctype_l (isprint_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:257:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:258:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  258 | __exctype_l (ispunct_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:258:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:259:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  259 | __exctype_l (isspace_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:259:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:260:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  260 | __exctype_l (isupper_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:260:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:261:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  261 | __exctype_l (isxdigit_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:261:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:263:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  263 | __exctype_l (isblank_l);
      | ^~~~~~~~~~~
/usr/include/ctype.h:263:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:267:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  267 | extern int __tolower_l (int __c, locale_t __l) __THROW;
      |                                                ^~~~~~~
/usr/include/ctype.h:267:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:268:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  268 | extern int tolower_l (int __c, locale_t __l) __THROW;
      |                                              ^~~~~~~
/usr/include/ctype.h:268:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:271:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  271 | extern int __toupper_l (int __c, locale_t __l) __THROW;
      |                                                ^~~~~~~
/usr/include/ctype.h:271:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/ctype.h:272:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  272 | extern int toupper_l (int __c, locale_t __l) __THROW;
      |                                              ^~~~~~~
/usr/include/ctype.h:272:46: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/errno.h:37:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   37 | extern int *__errno_location (void) __THROW __attribute_const__;
      |                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/errno.h:37:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:122:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  122 | extern char *setlocale (int __category, const char *__locale) __THROW;
      |                                                               ^~~~~~~
/usr/include/locale.h:122:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:125:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  125 | extern struct lconv *localeconv (void) __THROW;
      |                                        ^~~~~~~
/usr/include/locale.h:125:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:142:24: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  142 |       locale_t __base) __THROW;
      |                        ^~~~~~~
/usr/include/locale.h:142:24: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:176:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  176 | extern locale_t duplocale (locale_t __dataset) __THROW;
      |                                                ^~~~~~~
/usr/include/locale.h:176:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:180:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  180 | extern void freelocale (locale_t __dataset) __THROW;
      |                                             ^~~~~~~
/usr/include/locale.h:180:45: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/locale.h:187:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  187 | extern locale_t uselocale (locale_t __dataset) __THROW;
      |                                                ^~~~~~~
/usr/include/locale.h:187:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/c++/10/cmath:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from sumzero.cpp:2:
/usr/include/c++/10/bits/cpp_type_traits.h:500:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  500 |     __miter_base(_Iterator __it)
      |                                ^
In file included from /usr/include/c++/10/cmath:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from sumzero.cpp:2:
/usr/include/c++/10/ext/type_traits.h:152:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  152 |     __is_null_pointer(_Type* __ptr)
      |                                   ^
/usr/include/c++/10/ext/type_traits.h:157:28: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  157 |     __is_null_pointer(_Type)
      |                            ^
/usr/include/c++/10/ext/type_traits.h:162:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
  162 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
In file included from /usr/include/math.h:289,
                 from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from sumzero.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:22:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   22 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:22:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:26:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   26 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:26:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:30:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   30 | __MATHDECL_1 (int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                             ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:30:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:33:78: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   33 | __MATHDECL_1 (int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                              ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:33:78: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:36:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   36 | __MATHDECL_1 (int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
      |                                                                             ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:36:77: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from sumzero.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:39:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   39 | __MATHDECL_1 (int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));
      | ^~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:39:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/math.h:289,
                 from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from sumzero.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:43:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
   43 |      __attribute__ ((__const__));
      |                                ^
/usr/include/x86_64-linux-gnu/bits/mathcalls-helper-functions.h:43:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast'
In file included from /usr/include/features.h:461,