이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
#define pb push_back
#define all(v) (v).begin() , (v).end()
const int N = 2e5+ 4;
int n , T , q , m ;
signed main(){
cin>> n >> m ;
int a[n+1] , b[m] , ok =0 ;
for(int i= 1 ; i <= n ;i++)cin>> a[i];
for(int i =0 ; i < m; i++)cin>> b[i];
map<int, vector<vector<int>>>mp;
for(int j = 0 ; j < (1 << m )- 1; j++){
int x =0 ;
vector<int>v;
for(int u =0 ; u < m ; u++){
if((j >> u )&1){
x+=b[u];
v.pb(b[u]);
}
}
mp[x].pb(v);
}
queue<pair<int , map<int, int >>>q;
map<int ,int >h;
for(int i =0 ; i < m ; i++){
h[b[i]]++;
}
q.push({1 , h });
while(q.size()){
pair<int , map<int , int >> p= q.front();
q.pop();
int v = p.first ;
map<int ,int >us = p.second;
for(auto it:mp[a[v]]){
int ko =0 ;
for(auto at:it){
if(us[at])ko++;
us[at]--;
}
if(ko== it.size()){
if(v == n ){
cout << "YES";
return 0 ;
}
q.push({v + 1 ,us});
}
for(auto at:it){
us[at]++;
}
}
}
cout << "NO";
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In function 'int main()':
bank.cpp:43:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if(ko== it.size()){
| ~~^~~~~~~~~~~~
bank.cpp:11:25: warning: unused variable 'ok' [-Wunused-variable]
11 | int a[n+1] , b[m] , ok =0 ;
| ^~
# | 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... |