QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301523#2728. Boring LecturesCamillusCompile Error//Python31.7kb2024-01-10 00:48:552024-01-10 00:48:55

Judging History

你现在查看的是最新测评结果

  • [2024-01-10 00:48:55]
  • 评测
  • [2024-01-10 00:48:55]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

struct pair_hash {
    size_t operator()(const pair<int, int> &p) const {
        return p.first ^ p.second;
    }
};

static constexpr int maxn = 200000131;

int fff(int n, int m) {
    return ((1ll * n) << 26 | m) % maxn;
}

int saved_mx[maxn];

int mx_func(int n, int m) {
    if (n > m) {
        swap(n, m);
    }

    if (saved_mx[fff(n, m)]) {
        return saved_mx[fff(n, m)];
    }

    int cur = 0;

    if (n % 2 == 0 && m - n / 2 > 0) {
        cur = max(cur, mx_func(n, m - n / 2));
    }

    if (m % 2 == 0 && n - m / 2 > 0) {
        cur = max(cur, mx_func(n - m / 2, m));
    }

    if (m - 2 * n > 0) {
        cur = max(cur, mx_func(n, m - 2 * n));
    }

    if (n - 2 * m > 0) {
        cur = max(cur, mx_func(n - 2 * m, m));
    }

    return saved_mx[fff(n, m)] = cur + 1;
}

int saved_mn[maxn];

int mn_func(int n, int m) {
    if (n > m) {
        swap(n, m);
    }

    if (saved_mn[fff(n, m)]) {
        return saved_mn[fff(n, m)];
    }

    if (n == 2 * m || m == 2 * n) {
        return 1;
    }

    int cur = INT32_MAX;

    if (n % 2 == 0 && m - n / 2 > 0) {
        cur = min(cur, mn_func(n, m - n / 2));
    }

    if (m % 2 == 0 && n - m / 2 > 0) {
        cur = min(cur, mn_func(n - m / 2, m));
    }

    if (m - 2 * n > 0) {
        cur = min(cur, mn_func(n, m - 2 * n));
    }

    if (n - 2 * m > 0) {
        cur = min(cur, mn_func(n - 2 * m, m));
    }

    return saved_mn[fff(n, m)] = cur + 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;

    cout << mn_func(n, m) << ' ' << mx_func(n, m) << '\n';
    return 0;
}

詳細信息

  File "answer.code", line 13
    return ((1ll * n) << 26 | m) % maxn;
             ^
SyntaxError: invalid decimal literal