답안 #156522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156522 2019-10-06T10:14:21 Z a_player Detecting Molecules (IOI16_molecules) C++14
0 / 100
68 ms 65540 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back

using namespace std;

//typedef long long ll;

pair<int,int> dp[10001][10001];
int v[10001];

int N,uu,ll;

bool ric(int n,int val){
	if(val>=uu&&val<=ll){
    dp[n][val].f=1;
      dp[n][val].s=-2;
       return 1;
    }
	if(n==N)return 0;
	if(val>ll)return 0;
	if(dp[n][val].f!=-1)return dp[n][val].f;
	if(ric(n+1,val)){
		dp[n][val].f=1;
		dp[n][val].s=0;
		return 1;
		}
	else if(ric(n+1,val+v[n])){
		dp[n][val].f=1;
		dp[n][val].s=1;
		return 1;
		}
		else {
			dp[n][val].f=0;
			dp[n][val].s=-1;
			return 0;
			}
			return 0;
	}
vector<int> find_subset(int l,int u,vector<int> w){
  uu=l;
ll=u;
  N=w.size();
	for(int i=0;i<10001;i++)
	for(int j=0;j<10001;j++)dp[i][j]=mp(-1,-1);
    for(int i=0;i<w.size();i++)v[i]=w[i];
	ric(0,0);
  vector<int> sol;
	if(dp[0][0].f==0)return sol;
	int val=0;
	int n=0;
	while(dp[n][val].s!=-2){
		if(dp[n][val].s==1){
			sol.push_back(n);
			val+=v[n];
			n++;
			}else n++;
		}
		
		
	return sol;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++)v[i]=w[i];
                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 63 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -