Submission #841643

# Submission time Handle Problem Language Result Execution time Memory
841643 2023-09-01T19:07:27 Z Batrr Beech Tree (IOI23_beechtree) C++17
0 / 100
4 ms 18012 KB
#include "beechtree.h"
#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 300500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;

vector<pii> g[N];
int n, m;
int ans[N];
int P[N], C[N];

vector<int> t[N];

void dfs(int v) {
    t[v].pb(v);
    for (auto it: g[v]) {
        int to = it.s;
        dfs(to);
        for (auto x: t[to])
            t[v].pb(x);
    }
    sort(t[v].begin(), t[v].end());

    do {
        bool ok = 1;
        ok &= (t[v][0] == v);
        for (int i = 1; i < t[v].size(); i++) {
            int cnt = 0;
            for (int j = 0; j < i; j++)
                if (C[t[v][i]] == C[t[v][j]])
                    cnt++;
            ok &= (t[v][cnt] == P[t[v][i]]);
        }
        if (ok) {
            ans[v] = 1;
        }
    } while (next_permutation(t[v].begin(), t[v].end()));

}

vector<int> beechtree(int N, int M, vector<int> PP, vector<int> CC) {

    n = N;

    for (int i = 1; i < n; i++)
        g[i].pb({C[i], i});

    for (int i = 0; i < n; i++) {
        sort(g[i].begin(), g[i].end());
        P[i] = PP[i];
        C[i] = CC[i];
    }

    dfs(0);


    return vector<int>(ans, ans + n);
}

Compilation message

beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i = 1; i < t[v].size(); i++) {
      |                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 18012 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 18012 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 18012 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 18012 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 18012 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -