Submission #525078

#TimeUsernameProblemLanguageResultExecution timeMemory
525078ammar2000Magic Tree (CEOI19_magictree)C++17
0 / 100
2073 ms5960 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define F first #define S second #define coy cout<<"YES\n" #define con cout<<"NO\n" #define co1 cout<<"-1\n" #define sc(x) scanf("%lld",&x) #define all(x) x.begin(),x.end() #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int SI=3e5+7; ll INF=8e18+7; int dx[] = {1 , -1 , 0 , 0}; int dy[] = {0 , 0 , 1 , -1}; int MOD=1e9+7; vector <ll> bin; ll n,m,k,p[SI],r[SI],f[SI],t[SI]; bool UP(int node) { ll small=r[node]; while (node!=1) { if (t[node]==1&&r[node]<small) return 0; /* if (t[node]) cout << r[node]<<" "<<small <<"\n"; */ node=p[node]; // cout << node<<"\n"; } return 1; } int main() { fast cin>>n>>m>>k; swap (m,k); for (int i=2;i<=n;i++) cin>>p[i]; for (int i=0;i<k;i++) { ll a,b,c; cin>>a>>b>>c; r[a]=b; f[i]=a; } // for (int i=0;i<k;i++)\ cout << f[i]<<" "; ll e=(1<<k)-1; vector <ll> v; ll ans=0; for (int i=1;i<=e;i++) { v.clear(); for (int i=1;i<=n;i++) t[i]=0; for (int o=0;o<k;o++) { if (i&(1<<o)) v.pb(o),t[o]=1; } bool fl=1; for (auto y:v) { bool is=UP(f[y]); fl&=is; } if (fl&&ans<v.size()) ans=v.size(); } cout << ans <<"\n"; // use scanf not cin return 0; }

Compilation message (stderr)

magictree.cpp:48:3: warning: multi-line comment [-Wcomment]
   48 |   // for (int i=0;i<k;i++)\
      |   ^
magictree.cpp: In function 'int main()':
magictree.cpp:69:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |        if (fl&&ans<v.size())
      |                ~~~^~~~~~~~~
#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...