Search found 5 matches

by jiayaoyu
Wed Jan 22, 2003 12:50 am
Forum: Volume 4 (400-499)
Topic: 439 - Knight Moves
Replies: 33
Views: 11398

AC with D.P

Dijkstra is not very efficient.
I got AC after I switched to dynamic programming. :P

jhonny_yang,
the code here should give the correct answer as well, so generate all possible input and compare the output of my program with yours. Hope this can help.
by jiayaoyu
Tue Jan 21, 2003 6:23 pm
Forum: Volume 4 (400-499)
Topic: 439 - Knight Moves
Replies: 33
Views: 11398

why do i get TLE???

[c] #include <stdio.h> int graph[64][64]; int result[64][64]; int visited[64]; int len[64]; int dijkstra(int s,int d); void init() { int i,j; for(i = 0;i<8;i++) for(j = 0;j<8;j++) { if(i+2<8) { if(j-1>=0) graph[8*i+j][8*(i+2)+(j-1)] = 1; if(j+1<8) graph[8*i+j][8*(i+2)+(j+1)] = 1; } if(i+1<8) { if(j-...
by jiayaoyu
Sun Jan 19, 2003 4:46 pm
Forum: Volume 4 (400-499)
Topic: 497 - Strategic Defense Initiative
Replies: 144
Views: 22441

Could someone tell me why '1 3 2 5 4'should give '1 3 4'?

My prog(WA) gives '1 3 5', is there anything i missed out in the problem description?
by jiayaoyu
Sun Jan 19, 2003 1:40 pm
Forum: Volume 101 (10100-10199)
Topic: 10131 - Is Bigger Smarter?
Replies: 93
Views: 66406

10131 - Is Bigger Smarter?

[c] #include <stdio.h> int w[1001]; int s[1001]; int pre[1001]; int lens[1001]; void output(int last) { if(pre[last]==-1) printf("%d\n",last+1); else{ output(pre[last]); printf("%d\n",last+1); } } int main(int argc, char *argv[]) { int num=0,i,j,max = 1,last = 0; while(scanf("%d %d",&w[num],&s[num])...
by jiayaoyu
Sun Dec 22, 2002 8:57 pm
Forum: Volume 3 (300-399)
Topic: 349 - Transferable Voting (II)
Replies: 9
Views: 2491

If there were any invalid ballots, print an additional line

[c] //output
printf("Election #%d\n",elec);
printf(" %d bad ballot(s)\n",nbad);
[/c]

You should not output "0 bad ballot(s)" if there is none. [/cpp]

Go to advanced search