답안 #986380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986380 2024-05-20T12:14:14 Z FIFI_cpp Birokracija (COCI18_birokracija) C++17
70 / 100
82 ms 18468 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = long long;
#define pb push_back
#define all(a) a.begin(),a.end()
//#define int int64_t
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("fenceplan.in");
//ofstream fout ("fenceplan.out");
/*   /\_/\
*   (= ._.)
*   / >  \>
*/
// encouraging cat
const ll INF = 100000000000000;
const ll mod = 1000000007;
vector<vector<int>> adj;
vector<int> res;
int children(int curr)
{
    int s = 0;
    int r = 0;
    for (auto edge: adj[curr])
    {
        s += children(edge);
        r += res[edge];
    }
    res[curr] = r + s + 1;
    return s + 1;
}
int32_t main() {
    int n;
    cin >> n;
    adj.resize(n);
    res.resize(n);
    for (int i = 1;i < n;i++)
    {
        int from;
        cin >> from;
        from--;
        adj[from].pb(i);
        res[i] = 0;
    }
    children(0);
    for (int i = 0;i < n;i++)
    {
        cout << res[i] << " ";
    }
    cout << '\n';
    return 0;
}

Compilation message

birokracija.cpp:31:9: warning: "/*" within comment [-Wcomment]
   31 | /*   /\_/\
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1628 KB Output is correct
2 Correct 10 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 3932 KB Output is correct
2 Correct 25 ms 4444 KB Output is correct
3 Correct 26 ms 5972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 10568 KB Output is correct
2 Incorrect 70 ms 13836 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 10600 KB Output is correct
2 Correct 74 ms 12368 KB Output is correct
3 Incorrect 71 ms 15408 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 10488 KB Output is correct
2 Correct 71 ms 12828 KB Output is correct
3 Incorrect 75 ms 18468 KB Output isn't correct
4 Halted 0 ms 0 KB -