Submission #1107566

#TimeUsernameProblemLanguageResultExecution timeMemory
1107566the_ZHERBank (IZhO14_bank)C++17
100 / 100
180 ms19484 KiB
#include <bits/stdc++.h> #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int N=2e5+5; const int inf=1e9; const int mod=1e9+7; const int N1=1e6+1; vector<int>v; vector<int>v1; struct edge{ int v,time; }; vector<int>dp[1001]; bool used[21][(1<<20)]; int n,m; void dfs(int x,int msk){ if(x==n+1){ cout<<"YES\n"; exit(0); } if (used[x][msk]) { return; } used[x][msk] = true; for(int i=0;i<dp[v[x]].size();i++){ if((dp[v[x]][i]&msk)==0){ dfs(x+1,msk+dp[v[x]][i]); } } } signed main(){ // freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); boost; cin>>n>>m; v.push_back(0); v1.push_back(0); for(int i=0;i<n;i++){ int x; cin>>x; v.push_back(x); } for(int i=0;i<m;i++){ int x; cin>>x; v1.push_back(x); } for(int i=0;i<(1<<m);i++){ int cnt=0; for(int j=0;j<m;j++){ if(1&(i>>j)){ cnt+=v1[j+1]; } } if(cnt>1000){ continue; } dp[cnt].push_back(i); } dfs(1,0); cout<<"NO\n"; }

Compilation message (stderr)

bank.cpp: In function 'void dfs(int, int)':
bank.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<dp[v[x]].size();i++){
      |                 ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...