编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#25582 #1145. ddd 和渡渡鸟 Compile Error 0 0 ms 0 K C++ 17 (Clang) / 1.2 K q3540555 2020-05-27 15:21:38
显示原始代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
const int rge = 2e6;
ll arr[rge], psu[rge], idg[rge];
set<int> odg[rge];
vector<int> rk;
void solve() {
    ll a, b;
    cin >> a >> b;
    ll gab = gcd(a, b);
    ll ans = (a / gab) + (b / gab) - 2;
    ll n = (ans + 1) * (gab - 1) + ans;
    cout << n << endl;
    if (n > 1e6)
        return;
    for (int i = 1; i <= n - a; ++i) ++idg[i], odg[i + a].insert(i);
    for (int i = 1; i <= n - b; ++i) ++idg[i + b], odg[i].insert(i + b);
    queue<int> stp;
    for (int i = 1; i <= n; ++i)
        if (!idg[i])
            stp.push(i);
    while (!stp.empty()) {
        ll fnt = stp.front();
        stp.pop();
        rk.push_back(fnt);
        for (int x : odg[fnt]) {
            --idg[x];
            if (idg[x] == 0)
                stp.push(x);
        }
    }
    for (int i = 0; i < rk.size(); ++i) psu[rk[i]] = i;
    for (int i = 1; i <= n; ++i) arr[i] = psu[i] - psu[i - 1], printf("%d ", arr[i]);
    return;
}
int main() {
    solve();
    return 0;
}

编译信息

A MemoryLimitExceeded encountered while compiling your code.

clang: error: unable to execute command: Killed
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.1-svn347285-1~exp1~20181124105316.38 (branches/release_70)
Target: x86_64-pc-linux-gnux32
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/a-46afe0.cpp
clang: note: diagnostic msg: /tmp/a-46afe0.sh
clang: note: diagnostic msg: 

********************