题目链接:http://codeforces.com/problemset/problem/339/C
开个三维映射的map直接爆搜即可,记忆化下状态一共是1e7这样的级别
#include<bits/stdc++.h>
using namespace std;#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e3+10;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){ return y?gcd(y,x%y):x;}
char s[20];
int m,ans[maxn],cnt=0;
map<pair<int,pii>,int> mp;
int dfs(int res,int tim,int pre,int last){pair<int,pii> tmp=mk(res,mk(tim,last));if(mp[tmp]) return mp[tmp];if(res==0) return mp[tmp]=-1;if((res>0&&pre>0)||(res<0&&pre<0)) return mp[tmp]=-1;if(tim==m) return mp[tmp]=1;rep(i,0,10) if(s[i]=='1'&&last!=i+1){ans[cnt++]=i+1;if(tim%2==0){if(dfs(res+i+1,tim+1,res,i+1)==1) return 1;}else{if(dfs(res-i-1,tim+1,res,i+1)==1) return 1;}cnt--;}return mp[tmp]=-1;
}
int main(){scanf("%s%d",s,&m);int flag=0;for(int i=0;i<10;i++) if(s[i]=='1'){ans[cnt++]=i+1;if(dfs(i+1,1,-1,i+1)==1){flag=1;break;}cnt--;}if(flag){puts("YES");rep(i,0,cnt) cout<<ans[i]<<" ";}else{puts("NO");}return 0;
}