QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#544483#8943. Challenge Matrix Multiplicationucup-team4821#Compile Error//C++202.0kb2024-09-02 17:15:312024-09-02 17:15:32

Judging History

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

  • [2024-09-02 17:15:32]
  • 评测
  • [2024-09-02 17:15:31]
  • 提交

answer

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

const int N = 1000005, K = 65;
int n, m, k, in[N], out[N], ans[N], last[K][K], sum[K];
vector<int> e[N], ch[K];
bool to[K][N];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        ++in[v], ++out[u];
    }

    while (m > 0) {
        for (int i = 1; i <= n; ++i) {
            if (!in[i] && out[i]) {
                int u = i;
                ch[++k].push_back(u);
                while (!e[u].empty()) {
                    int v = e[u].back();
                    e[u].pop_back();
                    --out[u], --in[v];
                    u = v;
                    ch[k].push_back(v);
                    --m;
                }
            }
        }
    }

    for (int i = 1; i <= k; ++i) {
        for (int j = i + 1; j <= k; ++j) {
            last[i][j] = n + 1;
        }
    }

    for (int u = n; u >= 1; --u) {
        for (int i = 1; i <= k; ++i) {
            if (ch[i].empty() || ch[i].back() != u) continue;
            for (int j = i + 1; j <= k; ++j) {
                if (ch[j].empty() || ch[j].back() != u) continue;
                for (int x = last[i][j] - 1; x >= u; --x) {
                    if (to[i][x] || to[j][x]) {
                        if (!to[i][x]) {
                            to[i][x] = 1;
                            ++sum[i];
                        }
                        if (!to[j][x]) {
                            to[j][x] = 1;
                            ++sum[j];
                        }
                    }
                }
                last[i][j] = u;
            }
        }
        for (int i = 1; i <= k; ++i) {
            if (ch[i].empty() || ch[i].back() != u) continue;
            to[i][u] = 1;
            ++sum[i];
            ch[i].pop_back();
        }
        ans[u] = sum[i];
    }

    for (int i = 1; i <= n; ++i) cout << ans[i] << " \n"[i == n];

    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:69:22: error: ‘i’ was not declared in this scope
   69 |         ans[u] = sum[i];
      |                      ^