Submission #949038

#TimeUsernameProblemLanguageResultExecution timeMemory
949038IskachunBitwise (BOI06_bitwise)C++17
15 / 100
1073 ms432 KiB
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int mx;
void f(vector<pair<int,int>>& a, int pos, int curr) {
    if (pos == a.size()) {
        mx = max(mx, curr);
        //cout << curr << '\n';
        return;
    }
    for (int x = a[pos].first; x <= a[pos].second; x++) {
        //cout << x << ' ';
        f(a, pos + 1, curr | x);
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, p; cin >> n >> p;
    vector<int> k(p);
    for (int &x : k) cin >> x;
    int ans = (1ll << 31) - 1;
    for (int l : k) {
        vector<pair<int,int>> a(l);
        for (auto &x : a) cin >> x.first >> x.second;
        //for (auto x : a) cout << x.first << x.second << '\n';
        mx = 0;
        f(a, 0, 0);
        //cout << mx << '\n';
        ans &= mx;
    }
    cout << ans;
}

Compilation message (stderr)

bitwise.cpp: In function 'void f(std::vector<std::pair<int, int> >&, int, int)':
bitwise.cpp:8:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     if (pos == a.size()) {
      |         ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...