Submission #558663

#TimeUsernameProblemLanguageResultExecution timeMemory
558663OlympiaBitwise (BOI06_bitwise)C++17
0 / 100
1 ms224 KiB
#include <bits/stdc++.h> using namespace std; bool canDo (vector<pair<int,int>> &v, int x) { //can we achieve some supermask of x bool change = false; for (auto& p: v) { if ((int)log2(p.first) == (int)log2(p.second)) { int bt = (1 << (int)log2(p.first)); if (x & bt) x -= bt; p.first -= bt, p.second -= bt; change = true; } } for (auto& p: v) { if ((1 << (int)log2(p.second)) > x) { return true; } } int cntr = 0; for (auto& p: v) { cntr += ((1 << (int)log2(p.second)) == (1 << (int)log2(x))); } if (cntr >= 2) { return true; } for (auto& p: v) { if ((int)log2(p.second) == (int)log2(x)) { int bt = log2(x); p.second -= (1 << bt); } } return false; } int main() { int n, m; cin >> n >> m; int tot[m]; for (int i = 0; i < m; i++) { cin >> tot[i]; } vector<vector<pair<int,int>>> vec; int ind = 0; for (int i = 0; i < m; i++) { vec.emplace_back(); while (tot[i]--) { pair<int,int> p; cin >> p.first >> p.second; vec.back().push_back(p); } } cout << canDo(vec.back(), 4); return 0; for (int i = 0; i < vec.size(); i++) { for (auto& p: vec[i]) { cout << p.first << " " << p.second << " | "; } cout << '\n'; } }

Compilation message (stderr)

bitwise.cpp: In function 'bool canDo(std::vector<std::pair<int, int> >&, int)':
bitwise.cpp:6:10: warning: variable 'change' set but not used [-Wunused-but-set-variable]
    6 |     bool change = false;
      |          ^~~~~~
bitwise.cpp: In function 'int main()':
bitwise.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i = 0; i < vec.size(); i++) {
      |                     ~~^~~~~~~~~~~~
bitwise.cpp:45:9: warning: unused variable 'ind' [-Wunused-variable]
   45 |     int ind = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...