QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313654#5667. Meeting PlacesbllnWA 1ms3740kbC++11773b2024-01-24 21:56:502024-01-24 21:56:50

Judging History

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

  • [2024-01-24 21:56:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3740kb
  • [2024-01-24 21:56:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, o = 0, x, y, F[N], Dep[N], num[N], last[N], nxt[N];
int main() {
    queue<int> tot;
    tot.push(1);
    scanf("%d %d", &n, &m);
    for (int i = 2; i <= n; i++) scanf("%d", &F[i]), o++, nxt[o] = i, last[o] = num[F[i]], num[F[i]] = o;
    while (!tot.empty()) {
        x = tot.front();
        tot.pop();
        for (int i = num[x]; i; i = last[i]) Dep[nxt[i]] = Dep[x] + 1, tot.push(nxt[i]);
    }
    while (m--) {
        scanf("%d %d", &x, &y);
        while (x != y) {
            if (Dep[x] > Dep[y])
                x = F[x];
            else if (Dep[x] < Dep[y])
                y = F[y];
            else
                x = F[x], y = F[y];
        }
        printf("%d\n", x);
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3740kb

input:

100 23 213

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

wrong answer 1st numbers differ - expected: '1319350480.8007326', found: '0.0000000', error = '1.0000000'