답안 #1077070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077070 2024-08-26T22:18:39 Z Trent 참나무 (IOI23_beechtree) C++17
5 / 100
58 ms 6744 KB
#include "beechtree.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
#define asst(x) if(!(x)) exit(2)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

vi sub(int T, vi& P) {
    set<int> in;
    in.insert(T);
    int N = P.size();
    while(true) {
        bool hasNew = false;
        forR(i, N) {
            if(in.count(P[i]) && !in.count(i)) {
                hasNew = true;
                in.insert(i);
            }
        }
        if(!hasNew) break;
    }
    vi ret;
    for(int i : in) ret.push_back(i);
    return ret;
}

std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    vi ret(N);
    if(N <= 8) {
        forR(i, N) {
            vi vals = sub(i, P);
            sort(all(vals));
            bool found = false;
            do {
                bool can = true;
                map<int, int> freq;
                for(int j : vals) {
                    can = can && P[j] == vals[freq[C[j]]];
                    ++freq[C[j]];
                }
                found = found || can;
            } while(next_permutation(all(vals)));
            ret[i] = found;

        }
    }

    bool can = true;
    int lasCol = -1;
    for(int i = N-1; i >= 0; --i) {
        if(can) {
            ret[i] = 1;
            if(lasCol == -1) lasCol = C[i];
            else can = can && C[i] == lasCol;
        } else {
            ret[i] = 0;
        }
    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 4 ms 440 KB Output is correct
6 Correct 12 ms 432 KB Output is correct
7 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 4 ms 440 KB Output is correct
6 Correct 12 ms 432 KB Output is correct
7 Correct 44 ms 6740 KB Output is correct
8 Correct 42 ms 6744 KB Output is correct
9 Correct 0 ms 436 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 472 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 46 ms 6568 KB Output is correct
18 Correct 58 ms 6736 KB Output is correct
19 Correct 41 ms 6720 KB Output is correct
20 Correct 40 ms 6740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -