제출 #1219434

#제출 시각아이디문제언어결과실행 시간메모리
1219434AMel0nDetecting Molecules (IOI16_molecules)C++20
0 / 100
0 ms328 KiB
// subtask 3, 4 and possibly 5
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,N) for(ll i = 0; i < N; i++)
#define all(x) (x).begin(), (x).end()
#define F first 
#define S second

#include "molecules.h"

vector<int> find_subset(int l, int u, vector<int> W) {
    bitset<32> dp;
    dp[0] = 1;
    vector<int> res;
    int backtrack = -1;
    bool yes = 0;
    FOR(i, W.size()) {
        if (yes) break;
        for(ll w = u; w >= 0; w--) {
            if (w != 0 && w-W[i] >= 0) dp[w] = (dp[w-W[i]] == 1);
            if (l <= w && w <= u && dp[w])  {
                res.push_back(i);
                backtrack = w-W[i];
                yes = 1;
                break;
            }
        }
    }
    if (backtrack == -1) return res;
    while(backtrack != 0) {
        FOR(i,W.size()) {
            if (dp[backtrack-W[i]] == 1 && find(all(res), i) == res.end()) {
                res.push_back(i);
                backtrack = backtrack-W[i];
                break;
            }
        }
    }
    return res;
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...