| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么 不对? 我没说为啥WA,是样例都过不去。#include <iostream> using namespace std; int cases; int counter; int need[24]; int person[24]; struct Edge { int start,end,dis; }edge[200]; int bell(int inition) { int data[24]; int i,j; for(i=1;i<=23;i++) data[i]=99999999; data[0]=inition; for(i=0;i<25;i++) { bool yn=0; for(j=0;j<counter;j++) if(data[edge[j].start]+edge[j].dis<data[edge[j].end]) { data[edge[j].end]=data[edge[j].start]+edge[j].dis; yn=1; } if(yn==0) return data[23]; } return 0x7fffffff; } int main() { scanf("%d",&cases); while(cases--) { memset(person,0,sizeof(person)); counter=0; int n; int i; for(i=0;i<24;i++) scanf("%d",&need[i]); scanf("%d",&n); for(i=0;i<n;i++) { int tmp; scanf("%d",&tmp); person[tmp]++; } for(i=0;i<=23;i++) { edge[counter].start=i; edge[counter].end=(i-8+24)%24; edge[counter++].dis=-need[i]; edge[counter].start=i; edge[counter].end=(i-1+24)%24; edge[counter++].dis=0; edge[counter].start=(i-1+24)%24; edge[counter].end=i; edge[counter++].dis=person[i]; } int ans=0x7fffffff; for(i=0;i<=person[i];i++) if(ans>bell(i)) ans=bell(i); if(ans==0x7fffffff) printf("No Solution\n"); else printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator