code is getting wrong on test 1

Revision en1, by secomo, 2021-08-19 21:57:36

my code has worked on codeblocks and when I send it. it is getting wrong answer on test 1 and the test message form is: " Wrong outout formats (0 elements printed ) unexpected end of file "

any help would be great

Spoiler

include<bits/stdc++.h>

define int long long

define pb push_back

define cout cerr

define F first

define S second

using namespace std; const int N=1e5+5,M=1e4; long long minn=1e18,mux=-1e18; int n,k,cnt=1; const int mod=1e9+7; vectoradj[N],v; int b=0; int vis[N],ans[N], a[N]; void dfs(int node){ vis[node]=1; for(int i=0;i<adj[node].size();i++){ if(vis[adj[node][i]]==0){ ans[adj[node][i]]=max(ans[node]+1,ans[adj[node][i]]); dfs(adj[node][i]); } } } main() { int n; cin>>n; for(int i=0;i<n-1;i++){ int x,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x); } for(int i=1;i<=n;i++) cin>>a[i]; dfs(1); int b=0; for(int i=2;i<=n;i++) if(ans[a[i]]<ans[a[i-1]]) b=1; if(b==1) cout<<"No"<<endl; else cout<<"Yes"<<endl; return 0; }

Tags getting wrong answer, #confused

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English secomo 2021-08-19 21:58:55 21
en1 English secomo 2021-08-19 21:57:36 1245 Initial revision (published)