제출 #434604

#제출 시각아이디문제언어결과실행 시간메모리
434604KanaifuDetecting Molecules (IOI16_molecules)C++14
31 / 100
21 ms4548 KiB
#include <bits/stdc++.h>
#include "molecules.h"
//#include "grader.cpp"

using namespace std;
#define pb push_back
#define x first
#define y second

vector<int> find_subset(int l, int u, vector<int> w)
{
    vector <int> ret;
    pair<bool,bool> dp[1001][1001];
    for (int i=0; i<=1000; i++)
    {
        dp[i][0] = {1, 0};
        for (int j=1; j<=1000; j++)
        {
            dp[i][j] = {0, 0};
        }
    }
    for (int i=0; i<w.size(); i++)
    {
        for (int j=u; j>=0; j--)
        {
            if (i>0 and !(dp[i][j].x))
            {
                dp[i][j] = {dp[i-1][j].x, 0};
            }
            if (dp[i][j].x and dp[i][j].y==0)
            {
                if (j+w[i]<=u)
                {
                    dp[i][j+w[i]] = {1, 1};
                }
            }
        }
    }
    for (int j=l; j<=u; j++)
    {
        if (dp[w.size()-1][j].x)
        {
            int poz = w.size()-1;
            int weight = j;
            while (poz>=0)
            {
                if (dp[poz][weight].y)
                {
                    ret.pb(poz);
                    weight -= w[poz];
                }
                poz--;
            }
            break;
        }
    }
    return ret;
}

/*

4 15 17
6 8 8 7

*/

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i=0; i<w.size(); i++)
      |                   ~^~~~~~~~~
#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...