QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745806 | #9751. 覆盖一棵树 | xydCatGirl# | WA | 7ms | 3936kb | C++20 | 1.7kb | 2024-11-14 11:43:55 | 2024-11-14 11:44:01 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define pb emplace_back
#define For(i, x, y) for (int i = (x); i <= (y); i ++)
#define rep(i, x, y) for (int i = (x); i >= (y); i --)
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) (int)((v).size())
#define ull unsigned long long
#define ls (p << 1)
#define rs (p << 1 | 1)
#define mp make_pair
#define i128 __int128
#define db long double
#define vi vector< int >
#define mem(v, x) memset(v, x, sizeof(v))
#define A3 array< int, 3 >
#define A4 array< int, 4 >
#define vpii vector< pair< int, int > >
using namespace std;
mt19937_64 rnd(time(0));
template< typename T > void cmin(T &x, T y) { return x = min(x, y), void(); }
template< typename T > void cmax(T &x, T y) { return x = max(x, y), void(); }
int ksm(int x, int y, int p) {
int v = 1; x %= p;
while (y) v = 1ll * v * ((y & 1) ? x : 1) % p, x = 1ll * x * x % p, y >>= 1;
return (v % p + p) % p;
}
bool MemoryST;
const int N = 2e5 + 5;
const int mod = 998244353;
const long long INF = 1e18;
const int base = 13131;
int n, dep[N];
void Main() {
cin >> n;
dep[1] = 0;
int maxn = 0;
For (i, 2, n) {
int x; cin >> x; dep[i] = dep[x] + 1;
cmax(maxn, dep[i]);
}
cout << maxn << '\n';
return;
}
bool MemoryED;
signed main() {
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cerr << fixed << setprecision(6) << (&MemoryST - &MemoryED) / 1048576.0 << "MB\n";
int TESTCNT = 1;
cin >> TESTCNT;
while (TESTCNT --) Main();
cerr << endl << 1e3 * clock() / CLOCKS_PER_SEC << "ms";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3936kb
input:
2 8 1 2 3 2 5 1 7 8 1 2 3 4 5 6 7
output:
3 7
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3936kb
input:
33428 10 1 2 3 3 4 6 7 7 9 10 1 2 3 4 5 6 7 8 8 8 1 2 3 4 5 6 7 8 1 2 3 4 4 6 7 4 1 2 3 3 1 2 3 1 1 9 1 2 3 4 5 6 7 8 2 1 3 1 2 10 1 2 3 4 5 6 7 8 9 3 1 2 2 1 10 1 2 3 4 5 6 7 8 9 2 1 5 1 2 2 4 8 1 2 3 4 5 6 7 5 1 2 3 3 2 1 5 1 2 3 4 3 1 2 9 1 2 3 4 5 6 6 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 5 7 8 8 1 2 ...
output:
7 8 7 6 3 2 1 8 1 2 9 2 1 9 1 3 7 3 1 4 2 7 8 7 6 4 1 2 9 7 4 3 4 6 7 3 5 7 6 5 9 3 4 4 8 2 8 6 2 4 8 4 2 1 5 2 5 2 4 7 2 2 5 2 2 6 3 9 2 5 7 4 2 2 1 3 1 9 1 5 1 7 3 6 2 9 7 2 3 1 3 3 1 2 8 6 8 4 7 7 7 6 5 7 8 4 5 2 5 5 1 7 7 7 2 2 2 3 8 3 5 6 4 3 3 3 2 2 4 8 6 7 8 6 4 2 4 7 8 1 6 2 7 7 9 1 2 8 5 2 ...
result:
wrong answer 1st lines differ - expected: '4', found: '7'