Submission #855114

#TimeUsernameProblemLanguageResultExecution timeMemory
855114bestrazhuxpBank (IZhO14_bank)C++17
44 / 100
75 ms17172 KiB
#include <bits/stdc++.h> #define ll long long #define se second #define fi first #define pb push_back #define all(x) (x).begin() , (x).end() #define sz(x) (int)(x).size() #define BIT(x , i) ((x) >> (i) & 1) #define MASK(i) (1LL << (i)) #define name "1" #define task "" using namespace std; const int inf = 1e9 + 7; const ll linf = 1ll * inf * inf; const int mod = 1e9 + 7; const int maxn = 1e5 + 2; int f[1 << 21]; int a[21]; int b[21]; vector <int> s[maxn]; void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}} int n , m; int main() { file(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0 ; i < m; i++) cin >> b[i]; for(int i = 0 ; i < MASK(m) ; i++) { int sum = 0; for(int j = 0 ; j < m ; j++) if(BIT(i , j)) sum += b[j]; s[sum].pb(i); } memset(f , -1, sizeof f); f[0] = 0; for(int mask = 1; mask < MASK(n) ; mask++) { for(int j = 0 ; j < n; j++) { if(BIT(mask , j)) { int prev = mask ^ MASK(j); int x = f[prev]; if(x < 0) continue; for(auto y : s[a[j]]) { if(!(x & y)) { f[mask] = x ^ y; } } } } } if(f[MASK(n) - 1] < 0) return cout << "NO" , 0; cout << "YES"; }

Compilation message (stderr)

bank.cpp: In function 'void file()':
bank.cpp:23:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:23:82: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:23:151: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                                                                                                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:23:185: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 | void file(){if(fopen(task".inp" , "r")){freopen(task".inp" , "r" , stdin);freopen(task".out" , "w" , stdout);}else if(fopen(name".inp" , "r")){freopen(name".inp" , "r" , stdin);freopen(name".out" , "w" , stdout);}}
      |                                                                                                                                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...