제출 #887029

#제출 시각아이디문제언어결과실행 시간메모리
887029Alora은행 (IZhO14_bank)C++17
100 / 100
590 ms17180 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define all(x) x.begin(), x.end() #define VietAnh "Bank" #define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin()) #define getbit(x,i) ((x >> i)&1) #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define cntbit(x) __builtin_popcountll(x) #define fi(i, a, b) for(int i = a; i <= b; i++) #define fid(i, a, b) for(int i = a; i >= b; i--) #define maxn (int) (1e3 + 7) using namespace std; const ll mod = 1e9 + 7; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long GetRandom(long long l, long long r) { return uniform_int_distribution<long long> (l, r)(rng); } int n, m; int a[maxn], b[maxn]; vector<int> store[maxn]; void solve() { cin >> n >> m; fi(i, 1, n) cin >> a[i]; fi(i, 1, m) cin >> b[i]; fi(x, 1, (1 << m) - 1) { int s = 0; fi(i, 1, m){ s += getbit(x, i - 1) * b[i]; if(s > 1000) break; } if(s <= 1000) store[s].push_back(x); } unordered_set<int> tmp, curr; curr = {0}; fi(i, 1, n) { for(int x : curr){ for(int y : store[a[i]]) if((x & y) == 0) tmp.insert(x | y); } if(i == n && tmp.size() > 0){ cout << "YES\n"; return; } swap(curr, tmp); tmp.clear(); } cout << "NO\n"; } int main() { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(VietAnh".inp", "r")) { freopen(VietAnh".inp", "r", stdin); freopen(VietAnh".out", "w", stdout); } int nTest = 1; // cin >> nTest; while(nTest--) { solve(); } return 0; }

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

bank.cpp: In function 'void solve()':
bank.cpp:42:30: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   42 |             s += getbit(x, i - 1) * b[i];
      |                            ~~^~~
bank.cpp:8:28: note: in definition of macro 'getbit'
    8 | #define getbit(x,i) ((x >> i)&1)
      |                            ^
bank.cpp: In function 'int main()':
bank.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen(VietAnh".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(VietAnh".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...