제출 #521846

#제출 시각아이디문제언어결과실행 시간메모리
521846Kalashnikov은행 (IZhO14_bank)C++17
0 / 100
1091 ms204 KiB
#include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define all(a) a.begin() , a.end() #define F first #define S second using namespace std; using ll = long long; const int N = 20+5 , inf = 2e9 + 7; const ll INF = 1e18 , mod = 1e9+7 , P = 6547; int a[N] , b[N]; vector<int> ms; int n , m; void f(int sum , int pos = 1 , int cur = 0) { if(sum == 0) { ms.push_back(cur); return; } if(sum < b[pos]) return; f(sum-b[pos] , pos+1 , cur ^ (1 << pos-1)); f(sum , pos+1 , cur); } void solve(int tc) { cin >> n >> m; for(int i = 1; i <= n; i ++) { cin >> a[i]; } for(int i = 1; i <= m; i ++) { cin >> b[i]; } sort(b+1, b+m+1); vector<pair<int,int>> v; v.push_back({0 , 0}); for(int i = 1; i <= n; i ++) { int ok = 0; vector<pair<int,int>> cur; ms.clear(); f(a[i]); for(auto x: ms) { for(auto y: v) { if((x&y.F) == 0) { cur.push_back({x|y.F , y.S+1}); if(y.S+1 == n) { cout << "YES\n"; return; } } } } swap(cur , v); } cout << "NO"; } /* */ main() { ios; int tt = 1 , tc = 0; // cin >> tt; while(tt --) { solve(++tc); } return 0; }

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

bank.cpp: In function 'void f(int, int, int)':
bank.cpp:25:40: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   25 |  f(sum-b[pos] , pos+1 , cur ^ (1 << pos-1));
      |                                     ~~~^~
bank.cpp: In function 'void solve(int)':
bank.cpp:41:7: warning: unused variable 'ok' [-Wunused-variable]
   41 |   int ok = 0;
      |       ^~
bank.cpp: At global scope:
bank.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...