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
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
9 | awoo | 152 |
10 | luogu_official | 150 |
code is getting wrong on test 1
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
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; }
Название |
---|