제출 #68470

#제출 시각아이디문제언어결과실행 시간메모리
68470tatatan은행 (IZhO14_bank)C++11
100 / 100
802 ms18740 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; int vis[1<<20],n,mo,a[21],m[20],val[1<<20],x; vector<int> v[20005],ans[21]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>mo; for(int i=1;i<=n;++i) { cin>>a[i]; a[i]+=a[i-1]; } for(int i=0;i<mo;++i) cin>>m[i]; for(int i=0;i<(1<<mo);++i) { vis[i]=1; for(int j=0;j<mo;++j) if((1<<j)&i) val[i]+=m[j]; v[val[i]].pb(i); } for(int i=1;i<=n;++i) { for(int j=0;j<v[a[i]].size();++j) { if(vis[v[a[i]][j]]) ans[i].pb(v[a[i]][j]); } memset(vis,0,sizeof vis); queue<int> q; for(int j=0;j<ans[i].size();++j) { q.push(ans[i][j]); vis[ans[i][j]]=1; } while(!q.empty()) { x=q.front(); q.pop(); for(int j=0;j<mo;++j) if(!(x&(1<<j))&&!vis[x|(1<<j)]) { q.push(x|(1<<j)); vis[x|(1<<j)]=1; } } } if(ans[n].size()) cout<<"YES"<<endl; else cout<<"NO"<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:33:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<v[a[i]].size();++j) {
               ~^~~~~~~~~~~~~~~
bank.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<ans[i].size();++j) {
               ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...