답안 #502513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502513 2022-01-06T07:43:25 Z InternetPerson10 Magic Tree (CEOI19_magictree) C++17
14 / 100
139 ms 12176 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> adj(n);
    vector<ll> weight(n);
    vector<int> day(n);
    bool isLine = true;
    for(int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        adj[i].push_back(x);
        adj[x].push_back(i);
        if(x != i-1) isLine = false;
    }
    int maxWeight = -1, maxDay = -1, maxAdj = -1;
    for(int i = 0; i < m; i++) {
        int v, d, w;
        cin >> v >> d >> w;
        v--;
        weight[v] = w;
        day[v] = d;
        maxWeight = max(maxWeight, w);
        maxDay = max(maxDay, d);
        maxAdj = max(maxAdj, (int)adj[v].size());
    }
    ll ans = 0;
    if(isLine && maxWeight == 1) { // Longest increasing subsequence
        reverse(day.begin(), day.end());
        vector<int> day2;
        for(int d : day) if(d) day2.push_back(d);
        map<int, int> m;
        m[0] = 0;
        for(int i = 0; i < day2.size(); i++) {
            int w = day2[i];
            auto p = m.upper_bound(w);
            p--;
            m[w] = (*p).second + 1;
            auto it = m.find(w);
            auto pa = it;
            pa++;
            while(pa != m.end()) {
                if((*pa).second <= m[w]) m.erase(pa); 
                else break;
                pa = it;
                pa++;
            }
        }
        for(auto p : m) {
            ans = max(ans, (ll)p.second);
        }
    }
    else if(n <= 20 && k <= 20 && maxWeight == 1) {
        
    }
    else if(maxAdj == 1) {
        for(int w : weight) ans += w;
    }
    else if(k <= 2) {

    }
    else if(k <= 20 && maxWeight == 1) {

    }
    else if(m <= 1000) {

    }
    else if(maxWeight == 1) {

    }
    else {

    }
    cout << ans << '\n';
}

Compilation message

magictree.cpp: In function 'int main()':
magictree.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i = 0; i < day2.size(); i++) {
      |                        ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 7088 KB Output is correct
2 Correct 54 ms 6856 KB Output is correct
3 Correct 124 ms 7384 KB Output is correct
4 Correct 117 ms 7336 KB Output is correct
5 Correct 111 ms 7316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 102 ms 9460 KB Output is correct
5 Correct 139 ms 12176 KB Output is correct
6 Correct 131 ms 9508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 116 ms 7044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -