QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#458942#7615. Sequence FoldingkiaCompile Error//C++172.8kb2024-06-29 20:54:202024-06-29 20:54:20

Judging History

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

  • [2024-06-29 20:54:20]
  • 评测
  • [2024-06-29 20:54:20]
  • 提交

answer

/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

const int N = 3e5+23, lg = 18;
ll Mod = 1e9+7; //998244353;

inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
    ll ans = 1;
    a=MOD(a, mod);
    while (b) {
        if (b & 1) ans = MOD(ans*a, mod);
        b >>= 1;
        a = MOD(a*a, mod);
    }
    return ans;
}

ll t, n, m, a[N], cnt;
int dp[2][300*N];
set<ll> st;
vector<ll> vec;

bool get(ll x) {
    ll ptr = lower_bound(all(vec), x) - vec.begin();
    return(ptr<size(vec) && vec[ptr] == x); 
}

void divide(int id, ll v, ll h) {
    if(get(v) == 0) {
        dp[0][id] = 0, dp[1][id] = min(n/(1ll<<h), 1ll*m);
        return;
    }
    if((1ll<<h) == n) {
        if(st.find(v) != st.end()) {
            dp[0][id] = 1, dp[1][id] = 0;
        } else {
            dp[0][id] = 0, dp[1][id] = 1;
        }
        return;
    }

    ll lft=++cnt, rgt=++cnt;
    divide(lft, v, h+1); divide(rgt, (1ll<<(h+1))-v+1, h+1);

    dp[0][id] = min({
        dp[0][lft]+dp[0][rgt],
        dp[0][lft]+dp[1][rgt]+1,
        dp[1][lft]+dp[0][rgt]+1,
        dp[1][lft]+dp[1][rgt]+2,
        m
    });
    dp[1][id] = min({
        dp[0][lft]+dp[0][rgt]+2,
        dp[0][lft]+dp[1][rgt]+1,
        dp[1][lft]+dp[0][rgt]+1,
        dp[1][lft]+dp[1][rgt],
        m
    });
}

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n>>m; 
    ll num = 0;
    while((1ll<<num) < n) num++;
    
    // fuck(num);
    for(int i=1; i<=m; i++) {
        ll x; cin>>x;
        st.insert(x);
        
        vec.pb(x);
        for(ll h=num; h>0; h--) {
            if(x > (1ll<<(h-1)))x = (1ll<<h) - x + 1;
            vec.pb(x);
        }
    }
    vec.pb(1);
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());

    divide(++cnt, 1, 0);
    cout<<min(dp[0][1], dp[1][1]);

	return 0;
}

Details

answer.code: In function ‘void divide(int, ll, ll)’:
answer.code:70:20: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
   70 |     dp[0][id] = min({
      |                 ~~~^~
   71 |         dp[0][lft]+dp[0][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   72 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   74 |         dp[1][lft]+dp[1][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   75 |         m
      |         ~           
   76 |     });
      |     ~~              
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:4:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:70:20: note:   candidate expects 2 arguments, 1 provided
   70 |     dp[0][id] = min({
      |                 ~~~^~
   71 |         dp[0][lft]+dp[0][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   72 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   74 |         dp[1][lft]+dp[1][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   75 |         m
      |         ~           
   76 |     });
      |     ~~              
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:70:20: note:   candidate expects 3 arguments, 1 provided
   70 |     dp[0][id] = min({
      |                 ~~~^~
   71 |         dp[0][lft]+dp[0][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   72 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   74 |         dp[1][lft]+dp[1][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   75 |         m
      |         ~           
   76 |     });
      |     ~~              
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:70:20: note:   deduced conflicting types for parameter ‘_Tp’ (‘int’ and ‘long long int’)
   70 |     dp[0][id] = min({
      |                 ~~~^~
   71 |         dp[0][lft]+dp[0][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   72 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   74 |         dp[1][lft]+dp[1][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   75 |         m
      |         ~           
   76 |     });
      |     ~~              
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:70:20: note:   deduced conflicting types for parameter ‘_Tp’ (‘int’ and ‘long long int’)
   70 |     dp[0][id] = min({
      |                 ~~~^~
   71 |         dp[0][lft]+dp[0][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   72 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   73 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   74 |         dp[1][lft]+dp[1][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   75 |         m
      |         ~           
   76 |     });
      |     ~~              
answer.code:77:20: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
   77 |     dp[1][id] = min({
      |                 ~~~^~
   78 |         dp[0][lft]+dp[0][rgt]+2,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   79 |         dp[0][lft]+dp[1][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   80 |         dp[1][lft]+dp[0][rgt]+1,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~
   81 |         dp[1][lft]+dp[1][rgt],
      |         ~~~~~~~~~~~~~~~~~~~~~~
   82 |         m
      |         ~           
   83 |     });
      |     ~~              
/usr/include/c++/13/bits/stl_algobase.h:233:5...