Submission #502512

#TimeUsernameProblemLanguageResultExecution timeMemory
502512InternetPerson10Magic Tree (CEOI19_magictree)C++17
0 / 100
107 ms7040 KiB
#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(maxWeight == 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 (stderr)

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++) {
      |                        ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...