답안 #1083475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083475 2024-09-03T09:23:52 Z SamueleVid 참나무 (IOI23_beechtree) C++17
0 / 100
2000 ms 21072 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int MAXN = 2e5 + 5;
constexpr int MAXM = 2e5 + 5;
vector<int> P, C;
vector<int> curr;
deque<int> permutato;
vector<bool> v;
vector<int> adj[MAXN];
int colori_usati[MAXM];
bool sol[MAXN];

void vediamo(int u) {
    // cout << "vediamo " << u << '\n';
    // colori_usati[C[u]] ++;

    vector<int> to_remove;

    // cout << "colori_usati : ";
    // for (int i = 0; i < 4; i ++) cout << colori_usati[i] << " ";
    // cout << '\n';

    // cout << "permutazione da verificare per " << u << " : ";
    // for (auto x : permutato) cout << x << " ";
    // cout << '\n';



    for (int i = 1; i < permutato.size(); i ++) {
        int f_i = colori_usati[C[permutato[i]]];
        // cout << "permutato[i], f_i : " << permutato[i] << " " << f_i << '\n';
        if (P[permutato[i]] != permutato[f_i]) {
            for (auto x : to_remove) colori_usati[x] --;
            return;
        }
        to_remove.push_back(C[permutato[i]]);
        colori_usati[C[permutato[i]]] ++;
    }
    
    // cout << "permutazione valida per " << u << " : ";
    // for (auto x : permutato) cout << x << " ";
    // cout << '\n';


    // cout << "sol[u] = 1 !!" << '\n';
    
    for (auto x : to_remove) colori_usati[x] --;

    sol[u] = 1;

    // for (int i = 0; i < 4; i ++) cout << sol[i] << " ";
    // cout << '\n';
}

vector<int> beechtree(int N, int M, vector<int> P, vector<int> C) {
    ::P = P;
    ::C = C;
    for (int i = 1; i < N; i ++) {
        adj[P[i]].push_back(i);
        adj[i].push_back(P[i]);
    }

    fill(sol, sol + N, 0);
    fill(colori_usati, colori_usati + MAXM, 0);

    for (int i = N - 1; i >= 0; i --) {
        permutato.push_front(i);
        vediamo(i);
    }

    vector<int> res(N);
    for (int i = 0; i < N; i ++) res[i] = sol[i];
    return res;
}

Compilation message

beechtree.cpp: In function 'void vediamo(int)':
beechtree.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 1; i < permutato.size(); i ++) {
      |                     ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5720 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5896 KB Output is correct
3 Correct 2 ms 5908 KB Output is correct
4 Correct 3 ms 5908 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Incorrect 2 ms 5724 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5896 KB Output is correct
3 Correct 2 ms 5908 KB Output is correct
4 Correct 3 ms 5908 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5724 KB Output is correct
7 Correct 71 ms 21072 KB Output is correct
8 Correct 61 ms 21072 KB Output is correct
9 Correct 3 ms 5720 KB Output is correct
10 Correct 3 ms 5724 KB Output is correct
11 Correct 3 ms 5828 KB Output is correct
12 Correct 2 ms 5724 KB Output is correct
13 Correct 16 ms 5976 KB Output is correct
14 Correct 11 ms 5980 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 5 ms 5980 KB Output is correct
17 Execution timed out 2098 ms 19608 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5724 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5896 KB Output is correct
3 Incorrect 2 ms 5724 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5720 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5896 KB Output is correct
3 Incorrect 2 ms 5724 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5720 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5896 KB Output is correct
3 Incorrect 2 ms 5724 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5720 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -