Submission #558660

#TimeUsernameProblemLanguageResultExecution timeMemory
558660OlympiaBitwise (BOI06_bitwise)C++17
0 / 100
1 ms304 KiB
#include <iostream> #include <vector> #include <cmath> 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:8:10: warning: variable 'change' set but not used [-Wunused-but-set-variable]
    8 |     bool change = false;
      |          ^~~~~~
bitwise.cpp: In function 'int main()':
bitwise.cpp:58: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]
   58 |     for (int i = 0; i < vec.size(); i++) {
      |                     ~~^~~~~~~~~~~~
bitwise.cpp:47:9: warning: unused variable 'ind' [-Wunused-variable]
   47 |     int ind = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...