Submission #558660

# Submission time Handle Problem Language Result Execution time Memory
558660 2022-05-07T23:40:52 Z Olympia Bitwise (BOI06_bitwise) C++17
0 / 100
1 ms 304 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 304 KB Output isn't correct
2 Incorrect 0 ms 304 KB Output isn't correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 0 ms 300 KB Output isn't correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Incorrect 1 ms 212 KB Output isn't correct
18 Incorrect 1 ms 304 KB Output isn't correct
19 Incorrect 1 ms 304 KB Output isn't correct
20 Incorrect 1 ms 212 KB Output isn't correct