|
|
back to boardWA#33 Who can give me some tricky tests for this problem, please! Re: WA#33 Posted by PSV 3 Nov 2006 04:55 May be you need a more tricky algo? It's unable to have WA with this problem (quite simple algo) Re: WA#33 Please help, i have the same problem but i don't know where is my error here is code #include <iostream> using namespace std; int power[1005]; int deg[1005]; int mas[1005][1005]; int n,m; int answers[1006]; void input() { cin>>n>>m; int a,b; for(int i=0;i<m;i++) { cin>>a>>b; mas[a][power[a]++] = b; deg[b]++; } for(int i=0;i<n;i++) cin>>answers[i]; } void solve() { for(int i=0;i<n;i++) { if (deg[answers[i]]>0) { cout<<"NO"; return; } for(int j=0;j<power[answers[i]];j++) deg[mas[answers[i]][j]] --; } cout<<"YES"; } int main() { input(); solve(); return 0; } Re: WA#33 I don't know what are you doing, but you need just check M conditions for given sequence. I don't know what can be wrong. Edited by author 10.11.2006 04:29 Re: WA#33 Haha. I just changed int mas[1005][1005]; to int mas[1005][10005]; and get AC. I think that each limitation can occur in the input more than once i.e. some limitations can be equal :-p Advice: this solution use too much memory. Really you need less than 1 Mb. Edited by author 10.11.2006 14:02 Re: WA#33 Thank you for advise. Now i just changed adjanced list stored in array to vector<vector<int> > . And my programm used only 860 Kb. Re: WA#33 Haha. I just changed int mas[1005][1005]; to int mas[1005][10005]; and get AC. I think that each limitation can occur in the input more than once i.e. some limitations can be equal :-p Advice: this solution use too much memory. Really you need less than 1 Mb. Edited by author 10.11.2006 14:02 I'm very appreciate you. I used vector<vector<int> > and eventually got AC:-) Re: WA#33 Posted by MAK 12 Oct 2009 03:42 Thank you for the advice about limitations! Re: WA#33 Posted by LLL 2 Oct 2016 22:16 Thx! |
|
|