제출 #1197268

#제출 시각아이디문제언어결과실행 시간메모리
1197268andrejikusDetecting Molecules (IOI16_molecules)C++20
46 / 100
90 ms584 KiB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 1e4 + 3;
const int inf = 1e9;
int dp[N];

vector<int> find_subset(int l, int u, vector<int> w) {
    for (int i = 0; i < N; i++) dp[i] = inf;
    vector<int> res;

    dp[0] = 0;
    for (int i = 0; i < w.size(); i++) {
        for (int j = 0; j <= u; j++) {
            if (j-w[i] < 0) continue;
            if (dp[j-w[i]] == inf || dp[j-w[i]] == i+1) continue;
            dp[j] = min(dp[j], i+1);
        }
    }

    for (int t = l; t <= u; t++) {
        if (dp[t] == inf) continue;
        int j = t;

        while (j != 0) {
            res.push_back(dp[j]-1);
            j -= w[dp[j]-1];
        }
        if (j == 0) break;
    }
    sort(res.begin(), res.end());

    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...