Submission #1062690

# Submission time Handle Problem Language Result Execution time Memory
1062690 2024-08-17T09:53:01 Z nvujica Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define ll long long

using namespace std;

const int maxn = 5e5 + 100;

int n;
unsigned ll bio[maxn / 64];
unsigned ll bio2[maxn / 64];
int kada[maxn];

vector<int> find_subset(int l, int u, vector<int> w) {
    n = w.size();

    memset(kada, -1, sizeof kada);

    // for(int j = 63; j >= 0; j--){
    //     if(bio[0] && (1LL << j)) cout << 1;
    //     else cout << 0;
    // }
    // cout << endl;

    bio[0] = (1LL << 63);

    // cout << "prije ";

    // for(int j = 63; j >= 0; j--){
    //     if(bio[0] & (1LL << j)) cout << 1;
    //     else cout << 0;
    // }
    // cout << endl;


    for(int i = 0; i < n; i++){
        int d = w[i] / 64;
        int r = w[i] % 64;

        for(int j = 0; j < maxn / 64; j++){
            bio2[j] = bio[j];

            if(j - d >= 0) bio2[j] |= (bio[j - d] >> r);
            if(j - d - 1 >= 0) bio2[j] |= (bio[j - d - 1] << (64 - r));

            // for(int j = 63; j >= 0; j--){
            //     if(bio[0] & (1LL << j)) cout << 1;
            //     else cout << 0;
            // }
            // cout << endl;
        }

        for(int j = 0; j < maxn / 64; j++){
            if(bio2[j] != bio[j]){
                for(int b = 0; b < 64; b++){
                    if((bio2[j] & (1LL << b)) && !(bio[j] & (1LL << b))) kada[(j + 1) * 64 - 1 - b] = i;
                }

                bio2[j] = bio[j];
            }
        }
    }

    int x = 0;

    // for(int j = 63; j >= 0; j--){
    //     if(bio[0] & (1LL << j)) cout << 1;
    //     else cout << 0;
    // }
    // cout << endl;

    // for(int i = 0; i <= 10; i++){
    //     cout << kada[i] << ' ';
    // }
    // cout << endl;

    for(int i = l; i <= u; i++){
        if(kada[i] != -1){
            x = i;
            break;
        }
    }

    vector <int> v;

    while(x){
        v.push_back(kada[x]);
        x -= w[kada[x]];
    }
    
    reverse(v.begin(), v.end());

    return v;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2396 KB OK (n = 1, answer = YES)
4 Incorrect 1 ms 2392 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2396 KB OK (n = 1, answer = YES)
4 Incorrect 1 ms 2392 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2396 KB OK (n = 1, answer = YES)
4 Incorrect 1 ms 2392 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2396 KB OK (n = 1, answer = YES)
4 Incorrect 1 ms 2392 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2396 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2396 KB OK (n = 1, answer = YES)
4 Incorrect 1 ms 2392 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -