답안 #1055699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055699 2024-08-13T03:48:47 Z shjeong 참나무 (IOI23_beechtree) C++17
0 / 100
1 ms 5164 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pi;
#define all(x) x.begin(),x.end()
#define rll(x) x.rbegin(),x.rend()
ll n, m;
vector<ll> p, c;
vector<int> ans;
vector<ll> adj[202020];
void dfs(ll x){
    for(auto next : adj[x]){
        dfs(next);
    }
    set<ll> st;
    bool flag = 1;
    for(auto next : adj[x]){
        if(st.find(c[next]) != st.end()){
            flag = 0;
            break;
        }
        st.insert(c[next]);
    }
    ans[x] = flag;
    if(x==0 and flag){
        vector<pair<ll,map<ll,ll>>> v;
        for(auto next : adj[x]){
            if(!ans[next]){ans[x] = 0; return;}
            ll cnt = 0; map<ll,ll> mp;
            for(auto nnext : adj[next])cnt++, mp[c[nnext]]++;
            v.push_back({cnt,mp});
        }
        sort(rll(v));
        for(int i = 1 ; i < v.size() ; i++){
            for(auto [a,b] : v[i].second){
                if(v[i-1].second[a] < b){
                    ans[x] = 0;
                    return;
                }
            }
        }
    }
}
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    n=N,m=M;
    for(auto i : P)p.push_back(i);
    for(auto i : C)c.push_back(i);
    for(int i = 1 ; i < n ; i++)adj[P[i]].push_back(i);
    ans.resize(n);
    dfs(0);
    return ans;
}

Compilation message

beechtree.cpp: In function 'void dfs(ll)':
beechtree.cpp:34:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::map<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 1 ; i < v.size() ; i++){
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 5164 KB Output is correct
5 Incorrect 1 ms 4952 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Incorrect 1 ms 4956 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -