Submission #1328824

#TimeUsernameProblemLanguageResultExecution timeMemory
1328824rainerevan_Arranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 2e6 + 5;
const ll LOG = 30;
#define vll vector <ll>
#define pll pair <ll, ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " " << (x) << endl;

ll n, m;
ll a [30], b [30];
bool dp [30][MAXN];
vector <vll> v (30);

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    for(ll i = 0; i < m; i++){
        cin >> b[i];
    }
    ll tot = (1<<m);
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < tot; j++){
            ll cnt = 0;
            for(ll o = 0; o < m; o++){
                if((j>>o) & 1){
                    cnt += b[o];
                }
            }
            if(cnt == a[i]) v[i].push_back(j);
            // cout << i << " << ";
            // for(ll o = 0; o < m; o++){
            //     cout << ((j>>o) & 1);
            // }
            // cout << " << " << dp[i][j] << endl;
        }
    }
    for(ll i = 0; i < n; i++){
        for(auto j : v[i]){
            for(ll k = j; k < tot; k = (k+1) | j){
                if(i) dp[i][k] |= dp[i-1][k-j];
                else if(k == j) dp[i][k] = 1;
            }
        }
    }
    ll ans = 0;
    for(ll i = 0; i < tot; i++) ans |= dp[n-1][i];
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccE9tcB2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIx1rHX.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccE9tcB2.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status