10850 - The Gossipy Gossipers Gossip Gossips
Posted: Sat May 21, 2005 1:23 pm
Hi! Give me please critical input for this problem.
The Online Judge board
https://onlinejudge.org/board/
Code: Select all
const int MAX = 21;
int c[MAX][MAX][1000];
int d[MAX];
int tmp[1000];
void main()
{
int rez,times,q,f,t,i,j,tests,people,k,NO,aa,pp,ttt;
int *z;
deque<int> Q;
scanf("%d\n", &tests);
while(tests--)
{
memset(c,0,sizeof(c));
Q.clear();
scanf("%d %d", &people, &j);
for (i=1; i<=j; i++) {
scanf("%d %d %d", &f, &t, ×);
if (f==t) { for(k=1; k<=times; k++) scanf("%d", &ttt); continue; }
for (k=1; k<=times; k++) {
scanf("%d", &aa);
c[f][t][c[f][t][0]+k] = aa;
c[t][f][c[f][t][0]+k] = aa;
}
c[f][t][0]+=times;
c[t][f][0]+=times;
}
memset(d,-1,sizeof(d));
Q.push_back(1);
d[1]=0;
while (!Q.empty()) {
q = Q[0];
Q.pop_front();
for (i=1; i<=people; i++) {
if (i==q) continue;
if (c[q][i][0]) {
for (j=1; j<=c[q][i][0]; j++) {
// fill tmp array
memset(tmp,127,sizeof(tmp));
NO = tmp[0];
if (d[q]>c[q][i][j]) tmp[j]=(d[q]/100+1)*100+c[q][i][j];
else tmp[j]=c[q][i][j];
}
z = min_element(tmp, tmp+MAX);
if (*z!=NO) {
if (d[i]==-1 || d[i]>*z) {
d[i]=*z;
Q.push_back(i);
}
}
}
}
}
rez = 0;
for(i=2; i<=people; i++) {
if (d[i]==-1) rez = -1;
else if (d[i]>rez) rez = d[i];
}
printf("%d\n", rez);
}
}
How do you know it's still WA? I can't see that this problem has been added to volume 108 yet.oldbam wrote:Still WA.
Code: Select all
Code: Select all
6
2 1
2 2 1
3
5 5
1 2 1
10
1 3 1
5
3 4 1
6
2 4 1
7
2 5 1
8
4 3
1 2 1
60
2 3 1
40
4 3 1
30
3 2
1 2 1
42
2 3 1
42
5 5
1 3 2
60 70
1 4 3
20 22 24
4 5 1
10
3 5 2
12 80
3 2 2
55 78
8 0
-1
8
230
42
80
-1