이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,a[22],b[22];
vector<ll> isi[22];
void hai(ll aa,ll bb)
{
if(aa==(m+1))
{
if(bb==a[1])
{
cout<<"YES\n";
exit(0);
}
}
else
{
hai(aa+1,bb);
hai(aa+1,bb+b[aa]);
}
}
void cek(ll aa,ll bb,ll cc)
{
if(aa==(m+1))
{
if(bb==a[i])
{
isi[i].pb(cc);
}
}
else
{
cek(aa+1,bb,cc);
cek(aa+1,bb+b[aa],cc+(1<<(aa-1)));
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(i=1;i<=n;i++)cin>>a[i];
for(i=1;i<=m;i++)cin>>b[i];
if(1)
{
isi[0].pb(0);
for(i=1;i<=n;i++)
cek(1,0,0);
for(i=1;i<=n;i++)
{
vector<ll> tem;
ll ii,jj;
for(ii=0;ii<isi[i-1].size();ii++)
for(jj=0;jj<isi[i].size();jj++)
if(!(isi[i-1][ii]&isi[i][jj]))
tem.pb(isi[i-1][ii]|isi[i][jj]);
isi[i]=tem;
}
if(isi[n].empty())cout<<"NO\n";
else cout<<"YES\n";
}
else
{
hai(1,0);
cout<<"NO\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'int main()':
bank.cpp:56:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<isi[i-1].size();ii++)
~~^~~~~~~~~~~~~~~~
bank.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(jj=0;jj<isi[i].size();jj++)
~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |