답안 #898866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898866 2024-01-05T08:18:17 Z vjudge1 Magic Tree (CEOI19_magictree) C++17
3 / 100
32 ms 9676 KB
//In His Name
#include <bits/stdc++.h>
//#pragma GCC optimization("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 1e5 + 10, MOD = 1e9 + 7 ;
const ll INF = 1e18 + 100;

int n , m , k , v[maxn] ,d[maxn] , w[maxn] , dd[maxn];
vector<int> adj[maxn] , nums;

bool cmp(int x , int y){
    return (v[x] > v[y]);
}

int Lis(){
    int N = nums.size();
    vector<int> ans;
    ans.push_back(nums[0]);
    for (int i = 1; i < N ; i++) {
        if (nums[i] > ans.back())
            ans.push_back(nums[i]);

        else {
            int low = lower_bound(ans.begin(), ans.end(),nums[i])- ans.begin();
            ans[low] = nums[i];
        }
    }
    return ans.size();
}

void Sub(){
    cout << Lis();
}

int32_t main(){    
    ios_base::sync_with_stdio(false);
    cin.tie(0) , cout.tie(0);
    
    cin >> n >> m >> k;
    bool ok = true;
    for(int i = 2 ; i <= n ; i++){
        int p;
        cin >> p;
        adj[p].pb(i);
        if(p != i-1) ok = false;
    }
    int ans = 0;
    vector<int> x;
    for(int i = 1 ; i <= m ; i++){
        cin >> v[i] >> d[i] >> w[i];
        dd[v[i]] = d[i];
        x.pb(i);
        ans += w[i];
    }
    for(int i = n ; i > 1 ; i--) if(dd[i] != 0) nums.pb(dd[i]);
    if(ok) return Sub() , 0;
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 7136 KB Output is correct
2 Correct 16 ms 7940 KB Output is correct
3 Correct 27 ms 9048 KB Output is correct
4 Correct 24 ms 8744 KB Output is correct
5 Correct 28 ms 9420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 9676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -