Submission #490208

#TimeUsernameProblemLanguageResultExecution timeMemory
490208kaxzertBank (IZhO14_bank)C++17
100 / 100
489 ms82500 KiB
/** 00 00 11 00 00 111111 00000 111111 000000 00 00 1111 0000 11 00 11 11 000000 0000 11 11 00 11 00000 111111 00 00 00 11111111 0000 11 00 11 11 00 00 00 11 11 00 00 111111 00000 11 11 00 **/ #include<bits/stdc++.h> using namespace std; #define fto(i, a, b) for(int i = a; i <= b; ++i) #define fdto(i, a, b) for(int i = a; i >= b; --i) #define bugarr(a, i, j) cout << #a << "{" << i << "..." << j << "}:"; fto(k, i, j-1) cout << a[k] << ", "; cout << a[j] << endl; #define ll long long #define db double #define ldb long double #define ff first #define ss second #define pb push_back #define mp make_pair #define eb emplace_back #define vt vector #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define trav(i, a) for(auto &i : a) #define sz(a) (int)a.size() #define pi(a, b) pair<a, b> #define fast ios::sync_with_stdio(false); cin.tie(0) void setIO(string s) { if (sz(s) != 0) { freopen((s+".inp").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } void setIOusaco(string s) { if (sz(s) != 0) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } template<typename T, typename V> bool ckmin(T &a, V b) {return (b < a)? a = b, true : false;} template<typename T, typename V> bool ckmax(T &a, V b) {return (b > a)? a = b, true : false;} int f[27][(1<<(21))-1]; int n, m; vt<int> ke[27]; int dp(int i, int bitmask) { if (i == n) return 1; if (f[i][bitmask] != -1) return f[i][bitmask]; trav(u, ke[i]) { if ((bitmask&u)==0) { if (dp(i+1, bitmask|u)) return f[i][bitmask] = 1; } } return f[i][bitmask] = 0; } int main() { #ifndef TAP setIO(""); //setIOusaco("bank2014"); #endif fast; cin >> n >> m; vt<int> a(n); trav(i, a) cin >> i; vt<int> b(m); trav(i, b) cin >> i; fto(i, 0, n-1) { fto(j, 1, (1<<m)-1) { int li = j; int sum = 0; int pos = 0; while(li > 0) { sum += b[pos]*(li&1); ++pos; li >>= 1; } if (sum == a[i]) ke[i].pb(j); } } fto(i, 0, n-1) { fto(j, 0, (1<<m)-1) f[i][j] = -1; } cout << (dp(0, 0) ? "YES": "NO") << '\n'; return 0; }

Compilation message (stderr)

bank.cpp: In function 'void setIO(std::string)':
bank.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         freopen((s+".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp: In function 'void setIOusaco(std::string)':
bank.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((s+".out").c_str(),"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...