QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707318#2510. Make NumbersbecaidoCompile Error//C++202.1kb2024-11-03 15:28:462024-11-03 15:28:48

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 15:28:48]
  • 评测
  • [2024-11-03 15:28:46]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout<<"["<<#HEHE<<"] : ",dout(HEHE)
void dout(){cout<<'\n';}
template<typename T,typename...U>
void dout(T t,U...u){cout<<t<<(sizeof...(u)?", ":""),dout(u...);}
#else
#define debug(...) 7122
#endif

#define int long long
#define ll long long
#define Waimai ios::sync_with_stdio(false),cin.tie(0)
#define FOR(x,a,b) for(int x=a,I=b;x<=I;x++)
#define pb emplace_back
#define F first
#define S second

const int INF = 1e9;
const string str = "*+-";

void solve() {
    int a[4];
    FOR (i, 0, 3) cin >> a[i];
    set<int> s;
    sort (a, a + 4);
    do {
        FOR (mask, 1, 63) {
            vector<int> v;
            vector<char> c;
            int num = 0;
            int op[3];
            int x = mask;
            for (int j = 2; j >= 0; j--) op[j] = x % 4, x /= 4;
            FOR (i, 0, 3) {
                num = 10 * num + a[i];
                if (i == 3 || op[i] != 0) {
                    v.pb (num);
                    num = 0;
                }
                if (i < 3 && op[i] != 0) c.pb (str[op[i] - 1]);
            }
            vector<int> nv;
            vector<char> nc;
            num = -INF;
            FOR (i, 0, v.size() - 1) {
                if (num == -INF) num = v[i];
                else num *= v[i];
                if (i == v.size() - 1 || c[i] != '*') {
                    nv.pb (num);
                    if (i < c.size()) nc.pb (c[i]);
                    num = -INF;
                }
            }
            v = nv, c = nc;
            num = -INF;
            FOR (i, 0, v.size() - 1) {
                if (num == -INF) num = v[i];
                else if (c[i - 1] == '+') num += v[i];
                else num -= v[i];
            }
            if (num >= 0) s.insert (num);
        }
    } while (next_permutation (a, a + 4));
    cout << s.size() << '\n';
}

int32_t main() {
    Waimai;
	solve();
}

Details

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 answer.code:3:
/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
      |              ^~~~~~~~~~~~