답안 #173923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173923 2020-01-05T19:55:02 Z CaroLinda Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>

#define debug printf
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define ll long long
#define sz size()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define tiii tuple<int,int,int>
#define mkt make_tuple

const int MAX = 10010 ;

using namespace std ;

bool dp[MAX][MAX] ;

vector<int> find_subset(int l, int u, vector<int> w) 
{
    
	int cnt = 1 ;

	dp[0][0] = true ;

	for(int i : w)
	{
		
		for(int j = u ; j >= 0 ; j-- )
		{
			dp[cnt][j] = dp[cnt-1][j] ;
			if( j + i <= u )
				dp[cnt][j+i] |= dp[cnt-1][j] ;
		}

		cnt ++ ;

	}
			
	cnt -- ;

	vector<int> res ;

	int ok = -1 ;

	lp(i,l,u+1)
		if( dp[cnt][i] ) ok = i ;

	if( ok == -1 ) return res ;

	for(int i = cnt ; i > 0 ; i-- )
		if( dp[i][ok] && !dp[i-1][ok] )
		{
			res.pb(i) ;
			ok -= w[i-1] ;
		}

	sort(all(res));

	return res ;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 12, answer = YES)
2 Correct 2 ms 376 KB OK (n = 12, answer = YES)
3 Correct 2 ms 376 KB OK (n = 12, answer = NO)
4 Correct 2 ms 376 KB OK (n = 12, answer = NO)
5 Incorrect 3 ms 376 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -