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
# | User | Rating |
---|---|---|
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 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
9 | awoo | 153 |
10 | luogu_official | 150 |
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; }
Name |
---|
Auto comment: topic has been updated by secomo (previous revision, new revision, compare).
Please provide the problem link. It's not possible to find out the error without problem statement.
The code is unreadable, and you didn't provide the statement to the problem, it really looks like you don't want to be helped.
Fortunately for you, your mistake was simple: you used
#define cout cerr
. Cout writes in the standard output, which codeforces reads. Cerr writes in the error output which it doesn't.I don't know why you would put that line in and i recomend not using defines at all until you're experienced enough to understand when you shouldn't use it.