Submission #1306580

#TimeUsernameProblemLanguageResultExecution timeMemory
1306580kduckpDrvca (COCI19_drvca)C++20
Compilation error
0 ms0 KiB
/*
Author: duxp
Version: 1
Created at: 2025-12-30 20:33
*/
// ✅ Pragmas for Maximum Optimization in Competitive Programming
#pragma GCC optimize("O3,unroll-loops,inline,fast-math")
#pragma GCC target("avx,avx2,fma,sse,sse2,sse3,sse4,popcnt,tune=native")
#pragma GCC optimize("no-stack-protector")
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-variable"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int long long
#define pb push_back
#define all(x) x.begin() + 1, x.end()
#define nall(x) x.begin(), x.end()
#define vi vector<int>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

#define debug(x) cerr << #x << " = " << (x) << endl
#define debug2(x, y) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define debug3(x, y, z) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl

#define trailingzero(x) __builtin_ctzll(x)
#define cntbit1(x) __builtin_popcountll(x)
#define leadingzero(x) __builtin_clzll(x)

#define TDN signed main()
#define KILL() exit(0)
#define NAME "task"

template <typename T>
inline int getbit(T x, int k) { return (x >> k) & 1; }

template <typename T>
inline T onbit(T x, int k) { return x | (T(1) << k); }

template <typename T>
inline T offbit(T x, int k) { return x & ~(T(1) << k); }

template <typename T>
inline bool minimize(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
inline bool maximize(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1e18;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const int MAXN = 200000;
bool ok(vi a)
{
    if (a.size() == 0)
        return false;
    if (a.size() == 1)
        return true;

    int diff = a[1] - a[0];
    for (int i = 1; i < (int)a.size(); i++)
    {
        if (a[i] - a[i - 1] != diff)
            return false;
    }
    return true;
}

TDN
{
    fast;

    string fname = string(NAME);
    if (fopen((fname + ".inp").c_str(), "r"))
    {
        freopen((fname + ".inp").c_str(), "r", stdin);
        freopen((fname + ".out").c_str(), "w", stdout);
    }

    int n;
    cin >> n;

    vi a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    sort(all(a));

    vi diff;
    for (int i = 1; i <= n; i++)
    {
        diff.pb(a[i] - a[1]);
    }

    for (auto d : diff)
    {
        vector<bool> inA(n + 1, false);

        int last = a[1];
        inA[1] = true;

        for (int j = 2; j <= n; j++)
        {
            if (a[j] - last == d)
            {
                last = a[j];
                inA[j] = true;
            }
        }

        vi B;
        for (int j = 1; j <= n; j++)
        {
            if (!inA[j])
                B.pb(a[j]);
        }

        if (ok(B))
        {
            vi A;
            for (int j = 1; j <= n; j++)
            {
                if (inA[j])
                    A.pb(a[j]);
            }
            if (!ok(A) || A.size() + B.size() != n)
                continue;
            sort(nall(A));
            sort(nall(B));

            cout << A.size() << endl;
            for (auto x : A)
                cout << x << ' ';
            cout << endl;
            cout << B.size() << endl;
            for (auto x : B)
                cout << x << ' ';
            cout << endl;

            KILL();
        }
    }

    cout << -1;
    KILL();
}

Compilation message (stderr)

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from drvca.cpp:13:
/usr/include/c++/13/bits/allocator.h: In destructor 'constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~