#include "Annalib.h"
static long long D[300][300];
void Anna(int N,int M,int A[],int B[],long long C[],int Q,int S[],int T[],int K,int U[])
{
int i,j,k;
for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=4e18;
for(i=0;i<N;i++)D[i][i]=0;
for(i=0;i<M;i++)D[A[i]][B[i]]=C[i];
for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
for(i=0;i<Q;i++)
{
for(j=0;j<K;j++)if(D[S[i]][A[U[j]]]+C[U[j]]+D[B[U[j]]][T[i]]==D[S[i]][T[i]])break;
if(j<2)
{
Tap(0);
Tap(j&1);
}
else
{
Tap(1);
Tap(j>>2);
Tap(j&1);
}
}
}
#include "Brunolib.h"
static long long D[300][300];
static int V[300][300];
static void answer(int i,int j)
{
if(V[i][j]>0)Answer(V[i][j]-1);
if(V[i][j]<0)
{
answer(i,-V[i][j]-1);
answer(-V[i][j]-1,j);
}
}
void Bruno(int N,int M,int A[],int B[],long long C[],int Q,int S[],int T[],int K,int U[],int L,int X[])
{
int i,j,k;
for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=4e18;
for(i=0;i<M;i++)if(C[i]>0)
{
D[A[i]][B[i]]=C[i];
V[A[i]][B[i]]=i+1;
}
for(i=0;i<N;i++)
{
D[i][i]=0;
V[i][i]=0;
}
for(k=0;k<N;k++)for(i=0;i<N;i++)for(j=0;j<N;j++)if(D[i][j]>D[i][k]+D[k][j])
{
D[i][j]=D[i][k]+D[k][j];
V[i][j]=-k-1;
}
k=0;
for(i=0;i<Q;i++)
{
if(X[k]==0)
{
j=X[k+1];
k+=2;
}
else
{
j=((X[k]<<2)|(X[k+1]<<1)|X[k+2])-2;
k+=3;
}
if(j<K)
{
answer(S[i],A[U[j]]);
Answer(U[j]);
answer(B[U[j]],T[i]);
}
else answer(S[i],T[i]);
Answer(-1);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
11724 KB |
Output is correct - L = 29 |
2 |
Correct |
66 ms |
11724 KB |
Output is correct - L = 28 |
3 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 27 |
4 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 27 |
5 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 27 |
6 |
Correct |
65 ms |
11724 KB |
Output is correct - L = 24 |
7 |
Correct |
65 ms |
11724 KB |
Output is correct - L = 25 |
8 |
Correct |
72 ms |
11724 KB |
Output is correct - L = 20 |
9 |
Correct |
76 ms |
11724 KB |
Output is correct - L = 20 |
10 |
Correct |
81 ms |
11724 KB |
Output is correct - L = 20 |
11 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 3 |
12 |
Correct |
242 ms |
11724 KB |
Output is correct - L = 30 |
13 |
Correct |
65 ms |
11724 KB |
Output is correct - L = 22 |
14 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 158 |
2 |
Correct |
69 ms |
11724 KB |
Output is correct - L = 158 |
3 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 165 |
4 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 171 |
5 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 162 |
6 |
Correct |
55 ms |
11724 KB |
Output is correct - L = 164 |
7 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 178 |
8 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 179 |
9 |
Correct |
72 ms |
11724 KB |
Output is correct - L = 160 |
10 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 160 |
11 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 160 |
12 |
Correct |
65 ms |
11724 KB |
Output is correct - L = 180 |
13 |
Correct |
222 ms |
11724 KB |
Output is correct - L = 180 |
14 |
Correct |
72 ms |
11724 KB |
Output is correct - L = 164 |
15 |
Correct |
58 ms |
11724 KB |
Output is correct - L = 176 |
16 |
Correct |
75 ms |
11724 KB |
Output is correct - L = 180 |
17 |
Correct |
92 ms |
11724 KB |
Output is correct - L = 124 |
18 |
Correct |
84 ms |
11724 KB |
Output is correct - L = 148 |
19 |
Correct |
62 ms |
11724 KB |
Output is correct - L = 180 |
20 |
Correct |
76 ms |
11724 KB |
Output is correct - L = 180 |
21 |
Correct |
88 ms |
11724 KB |
Output is correct - L = 180 |
22 |
Correct |
52 ms |
11724 KB |
Output is correct - L = 160 |
23 |
Correct |
65 ms |
11724 KB |
Output is correct - L = 160 |
24 |
Correct |
59 ms |
11724 KB |
Output is correct - L = 160 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
11724 KB |
Output is correct - L = 158 |
2 |
Correct |
59 ms |
11724 KB |
Output is correct - L = 158 |
3 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 165 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 158 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
11724 KB |
Output isn't correct - L = 158 |
2 |
Incorrect |
59 ms |
11724 KB |
Output isn't correct - L = 158 |
3 |
Incorrect |
65 ms |
11724 KB |
Output isn't correct - L = 165 |
4 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 171 |
5 |
Incorrect |
58 ms |
11724 KB |
Output isn't correct - L = 162 |
6 |
Incorrect |
72 ms |
11724 KB |
Output isn't correct - L = 164 |
7 |
Incorrect |
78 ms |
11724 KB |
Output isn't correct - L = 178 |
8 |
Incorrect |
72 ms |
11724 KB |
Output isn't correct - L = 179 |
9 |
Incorrect |
58 ms |
11724 KB |
Output isn't correct - L = 160 |
10 |
Incorrect |
66 ms |
11724 KB |
Output isn't correct - L = 160 |
11 |
Incorrect |
55 ms |
11724 KB |
Output isn't correct - L = 160 |
12 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 180 |
13 |
Incorrect |
192 ms |
11724 KB |
Output isn't correct - L = 180 |
14 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 164 |
15 |
Incorrect |
69 ms |
11724 KB |
Output isn't correct - L = 176 |
16 |
Incorrect |
78 ms |
11724 KB |
Output isn't correct - L = 180 |
17 |
Incorrect |
92 ms |
11724 KB |
Output isn't correct - L = 124 |
18 |
Incorrect |
92 ms |
11724 KB |
Output isn't correct - L = 148 |
19 |
Incorrect |
62 ms |
11724 KB |
Output isn't correct - L = 180 |
20 |
Incorrect |
72 ms |
11724 KB |
Output isn't correct - L = 180 |
21 |
Incorrect |
92 ms |
11724 KB |
Output isn't correct - L = 180 |
22 |
Incorrect |
68 ms |
11724 KB |
Output isn't correct - L = 160 |
23 |
Incorrect |
65 ms |
11724 KB |
Output isn't correct - L = 160 |
24 |
Incorrect |
72 ms |
11724 KB |
Output isn't correct - L = 160 |