Submission #898888

#TimeUsernameProblemLanguageResultExecution timeMemory
898888vjudge1Magic Tree (CEOI19_magictree)C++17
14 / 100
38 ms13256 KiB
//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; struct hoom{ int v , d , w; }; int n , m , k ; vector<int> adj[maxn] , nums; vector<hoom> mive; bool cmp(hoom x , hoom y){ return (x.v < y.v); } void Sub3(){ for(auto i : mive) nums.pb(i.d); reverse(all(nums)); vector<int> ans; int N = nums.size(); for (int i = 0; i < N; i++) { auto it = upper_bound(ans.begin(), ans.end(), nums[i]); if (it == ans.end()) { ans.push_back(nums[i]); } else { *it = nums[i]; } } cout << ans.size(); } void Sub2(){ } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0) , cout.tie(0); cin >> n >> m >> k; bool is1 = true , is3 = true; if(n > 20) is1 = false; for(int i = 2 ; i <= n ; i++){ int p; cin >> p; adj[p].pb(i); if(p != i-1) is3 = false; } int sum = 0; for(int i = 1 ; i <= m ; i++){ int a , b , c; cin >> a >> b >> c; sum += c; if(c != 1) is3 = false; mive.pb({a , b , c}); } sort(all(mive) ,cmp); if(is3){ Sub3(); return 0; } cout << sum; }

Compilation message (stderr)

magictree.cpp: In function 'int32_t main()':
magictree.cpp:56:10: warning: variable 'is1' set but not used [-Wunused-but-set-variable]
   56 |     bool is1 = true , is3 = true;
      |          ^~~
#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...