10850 - The Gossipy Gossipers Gossip Gossips
Moderator: Board moderators
10850 - The Gossipy Gossipers Gossip Gossips
Hi! Give me please critical input for this problem.
Life is beautifull !!!
-
- Guru
- Posts: 584
- Joined: Thu Jun 19, 2003 3:48 am
- Location: Sanok, Poland
- Contact:
Still WA. I receive right answer on
4 1 1
0
2 4 1
1
3 4 1
1
I use BFS search. Why here can be a problem. All the times i keep in the array c[][][], where c[j][0]-number of times when person i meets person j.
I post my code. Maybe someone will see some mistakes, as i'm already tired of thinking about this problem.
4 1 1
0
2 4 1
1
3 4 1
1
I use BFS search. Why here can be a problem. All the times i keep in the array c[][][], where c[j][0]-number of times when person i meets person j.
I post my code. Maybe someone will see some mistakes, as i'm already tired of thinking about this problem.
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);
}
}
Life is beautifull !!!
-
- Experienced poster
- Posts: 151
- Joined: Tue Nov 16, 2004 7:23 pm
- Location: Norway
- Contact:
Hi! After several WAs im bagging for help 
My algorithm is as follows:
I sort the times and doing simulation until there wasnt a meeting with changing news in the last 100 ticks.
I got right answers on every test case posted here and that i could think of. Maybe i missed something :/
Here comes the code:

My algorithm is as follows:
I sort the times and doing simulation until there wasnt a meeting with changing news in the last 100 ticks.
I got right answers on every test case posted here and that i could think of. Maybe i missed something :/
Here comes the code:
Code: Select all
-
- New poster
- Posts: 28
- Joined: Mon Mar 01, 2004 11:29 pm
10850 - The Gossipy Gossipers Gossip Gossips - WA
Hi guys,
I try to solve the 10850 and receive many WA. I think that this problem is shortest-path.
I create this output:
And my answer is
Thanks!
I try to solve the 10850 and receive many WA. I think that this problem is shortest-path.
I create this output:
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
Thanks!
-
- New poster
- Posts: 28
- Joined: Mon Mar 01, 2004 11:29 pm