Submission #972758

#TimeUsernameProblemLanguageResultExecution timeMemory
972758saidponBank (IZhO14_bank)C++14
0 / 100
24 ms57948 KiB
#include <bits/stdc++.h> #define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> #define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define allr(pon) pon.rbegin(), pon.rend() #include <ext/pb_ds/assoc_container.hpp> #define all(pon) pon.begin(), pon.end() #include <ext/pb_ds/tree_policy.hpp> #define pii pair <int, int> #define nosolve puts("-1") #define YES puts("YES") #define pb push_back #define pf push_front #define int long long #define OK puts("OK") #define NO puts("NO") #define sigma signed #define sc second #define fr first using namespace __gnu_pbds; using namespace std; const int N = 1e6 + 20, INF = 2e9 + 7; int a[N], b[N]; vector <string> pon[N]; string bit[N]; string v2(int x, int k){ string s = ""; while (x != 0){ s.pb((x % 2) + '0'); x /= 2; } if (s.size() < k){ while (s.size() < k) s.pb('0'); } reverse (s.begin(), s.end()); return s; } sigma main(){ nemeshay int n, m, dva = 1; cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++){ cin >> b[i]; dva *= 2; } for (int i = 0; i < dva; i++){ bit[i] = (v2(i, m)); } pon[0].pb(bit[0]); for (int i = 1; i <= n; i++){ if (pon[i - 1].empty()){ NO; return 0; } for (int j = 0; j < dva; j++){ int sum = 0; for (int l = 0; l < bit[j].size(); l++){ if (bit[j][l] == '1') sum += b[i + 1]; } if (sum == a[i]){ for (auto l: pon[i - 1]){ int da = 1; for (int k = 0; k < l.size(); k++){ if (bit[j][k] == l[k] && l[k] == '1'){ da = 0; break; } } if (da) pon[i].pb(bit[j]); } } } } if (pon[n].empty()) NO; else YES; }

Compilation message (stderr)

bank.cpp: In function 'std::string v2(long long int, long long int)':
bank.cpp:31:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   31 |     if (s.size() < k){
      |         ~~~~~~~~~^~~
bank.cpp:32:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   32 |         while (s.size() < k) s.pb('0');
      |                ~~~~~~~~~^~~
bank.cpp: In function 'int main()':
bank.cpp:57:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for (int l = 0; l < bit[j].size(); l++){
      |                             ~~^~~~~~~~~~~~~~~
bank.cpp:63:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |                     for (int k = 0; k < l.size(); k++){
      |                                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...