제출 #1129404

#제출 시각아이디문제언어결과실행 시간메모리
1129404NAMINDetecting Molecules (IOI16_molecules)C++20
31 / 100
1095 ms580 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; /*pair<vector<int>,bool> solve(int l,int u,vector<pair<int,int>>& W){ if(l <= 0) return {{},true}; vector<int> ans; bool ok = false; for(int i=0;i<W.size();i++){ if(W[i].first > u || take[i]) continue; take[i] = true; auto res = solve(l-W[i].first,u-W[i].first,W); ans = res.first; ans.push_back(W[i].second); ok = res.second; if(ok){ break; } else ans = vector<int>(); take[i] = false; } return {ans,ok}; }*/ vector<int> solve(int l,int u,vector<int>& w){ vector<bool> dp(1e6+1,false); dp[0] = true; int n = w.size(); for(int i=0;i<n;i++){ for(int j=1e6;j>=0;j--){ if(j+w[i] <= 1e6 && dp[j]){ dp[j+w[i]] = true; } } } vector<int> ans; for(int i=l;i<=u;i++){ if(dp[i]){ vector<int> take(n,false); for(int j=0;j<n;j++){ if(i-w[j] >= 0){ if(dp[i-w[j]] && !take[j]){ ans.push_back(j); take[j] = true; i-=w[j]; j = 0; } } } break; } } return ans; } vector<int> find_subset(int l, int u,vector<int> w) { return solve(l,u,w); }

컴파일 시 표준 에러 (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...