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 | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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.