답안 #1062685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062685 2024-08-17T09:50:24 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 < 100 / 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));

            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;
                }
            }

            bio[j] = bio2[j];

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

    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 2396 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2136 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 2396 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 2396 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 2396 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 2396 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -