bool wordBreak(std::string s, std::vector<std::string>& wordDict) {
std::vector<int> dp(s.size()+1);
dp[0]=1;
for(int i=1;i<s.size()+1;i++){
for(int j=0;j<=i;j++){
if(dp[j]&&std::find(wordDict.begin(),wordDict.end(),s.substr(j,i-j))!=wordDict.end()){
dp[i]=1;
}
}
}
return dp[s.size()];
}