Submission #439318

# Submission time Handle Problem Language Result Execution time Memory
439318 2021-06-29T15:07:15 Z Sara Sob (COCI19_sob) C++14
10 / 110
144 ms 6048 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define F first
#define S second
#define pb push_back
#define md ((b + e) >> 1)
#define lc (ind << 1)
#define rc (lc | 1)

const ll N = 1e6+ 10;
const ll lg = 15;
const ll oo = 1e9 + 10;
const ll mod = 1e9 + 7;

vector < pair <int, int> > solve(int n, int m){
    vector < pair <int, int> > ret = {};

    if (n <= 3){
        vector <int> A = {}, B = {};
        for (int i = 0; i < n; i ++){
            A.pb(i);
            B.pb(m + i);
        }
        do {
            bool ok = 1;
            for (int i = 0; i < n; i ++){
                ok &= ((A[i] & B[i]) == A[i]);
            }
            if (ok){
                break;
            }
        } while (next_permutation(B.begin(), B.end()));
        for (int i = 0; i < n; i ++){
            ret.pb({A[i], B[i]});
        }
        return ret;
    }

    vector < pair <int, int> > o = {}, e = {};
    if (n & 1){
        if (m & 1){
            o = solve((n - 2) / 2 + 1, m / 2);
            e = solve((n - 1) / 2 + 1, (m + 2) / 2);
        }
        else {
            o = solve((n - 2) / 2 + 1, (m + 1) / 2);
            e = solve((n - 1) / 2 + 1, m / 2);
        }
    }
    else {
        if (m & 1){
            o = solve((n - 1) / 2 + 1, m / 2);
            e = solve((n - 2) / 2 + 1, (m + 1) / 2);
        }
        else {
            o = solve((n - 1) / 2 + 1, (m + 1) / 2);
            e = solve((n - 2) / 2 + 1, m / 2);
        }
    }
    for (auto it : o){
        ret.pb({it.F * 2 + 1, it.S * 2 + 1});
    }
    for (auto it : e){
        ret.pb({it.F * 2, it.S * 2});
    }
    return ret;
}

int n, m;
vector < pair <int, int> > ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    ans = solve(n, m);
    for (auto it : ans){
        cout << it.F << ' ' << it.S << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 144 ms 6048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Integer parameter [name=y] equals to 8447, violates the range [4815, 8191]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Integer parameter [name=y] equals to 899, violates the range [647, 886]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 144 ms 6048 KB Output is correct
5 Incorrect 2 ms 332 KB Integer parameter [name=y] equals to 8447, violates the range [4815, 8191]
6 Halted 0 ms 0 KB -