Submission #92699

# Submission time Handle Problem Language Result Execution time Memory
92699 2019-01-04T10:31:50 Z janchomath Bootfall (IZhO17_bootfall) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[5001],k[5001],dp[5001][5001],ans,ind,p;
vector<ll>v;
int main(){
	std::ios::sync_with_stdio(false);
	cin >> n;
	
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	
	for(int i=1; i<=n; i++){
		cin >> k[i];
	}
	
	for(int i=1; i<=n; i++)dp[i][1] = i;
	ans = 1;
	ind = 1;
	for(int i=1; i<=n; i++){
		p = -1;
		for(int j = i-1; j>=1; j--){
			if(__builtin_popcount((a[j]&a[i])) == k[i]){
				p = j;
				break;
			}
		}
		if(p==-1)continue;
		for(int j=2; j<=n; j++){
			if(dp[p][j-1])dp[i][j] = p;
			if(dp[i][j] && j > ans){
				ans = j;
				ind = i;
			}
		}
	}
	
	cout << ans << endl;
	
	while(dp[ind][ans] != ind){
		v.pb(ind);
		ind = dp[ind][ans];
		ans--;
	}
	v.pb(ind);
	
	for(int i=(int)v.size()-1; i>=0; i--){
		cout << v[i] << " ";
	}
	
	
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -