Submission #6143

# Submission time Handle Problem Language Result Execution time Memory
6143 2014-06-20T09:39:17 Z gs13068 한자 끝말잇기 (JOI14_kanji) C++
32 / 100
265 ms 12428 KB
#include "Annalib.h"

static long long D[300][300];
static long long D2[300][300];
static int yes[5];

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,l;
  for(i=0;i<N;i++)for(j=0;j<N;j++)D[i][j]=D2[i][j]=4e18;
  for(i=0;i<M;i++)
  {
    D[A[i]][B[i]]=C[i];
    for(j=0;j<K;j++)if(i==U[j])break;
    if(j==K)D2[A[i]][B[i]]=C[i];
  }
  for(i=0;i<N;i++)D[i][i]=D2[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];
    if(D2[i][j]>D2[i][k]+D2[k][j])D2[i][j]=D2[i][k]+D2[k][j];
  }
  for(i=0;i<Q;i++)
  {
    k=0;
    for(j=0;j<K;j++)if(D2[S[i]][A[U[j]]]+D2[B[U[j]]][T[i]]<D2[S[i]][T[i]])yes[k++]=j;
    for(j=0;j<k;j++)if(D[S[i]][A[U[yes[j]]]]+C[U[yes[j]]]+D[B[U[yes[j]]]][T[i]]==D[S[i]][T[i]])break;
    if(k<4)
    {
      Tap(j>>1);
      Tap(j&1);
    }
    else
    {
      Tap(j>>2);
      Tap((j>>1)&1);
      Tap(j&1);
    }
  }
}
#include "Brunolib.h"

static long long D[300][300];
static int V[300][300];
static int yes[5];

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,l;
  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;
  }
  l=0;
  for(i=0;i<Q;i++)
  {
    k=0;
    for(j=0;j<K;j++)if(D[S[i]][A[U[j]]]+D[B[U[j]]][T[i]]<D[S[i]][T[i]])yes[k++]=j;
    if(k<4)
    {
      j=(X[l]<<1)|X[l+1];
      l+=2;
    }
    else
    {
      j=(X[l]<<2)|(X[l+1]<<1)|X[l+2];
      l+=3;
    }
    if(j<k)
    {
      j=yes[j];
      answer(S[i],A[U[j]]);
      Answer(U[j]);
      answer(B[U[j]],T[i]);
    }
    else answer(S[i],T[i]);
    Answer(-1);
  }
}

Compilation message

Anna.cpp: In function 'void Anna(int, int, int*, int*, long long int*, int, int*, int*, int, int*)':
Anna.cpp:9:13: warning: unused variable 'l' [-Wunused-variable]
   int i,j,k,l;
             ^
# Verdict Execution time Memory Grader output
1 Correct 82 ms 12428 KB Output is correct - L = 20
2 Correct 102 ms 12428 KB Output is correct - L = 20
3 Correct 86 ms 12428 KB Output is correct - L = 20
4 Correct 76 ms 12428 KB Output is correct - L = 20
5 Correct 82 ms 12428 KB Output is correct - L = 20
6 Correct 75 ms 12428 KB Output is correct - L = 21
7 Correct 81 ms 12428 KB Output is correct - L = 24
8 Correct 106 ms 12428 KB Output is correct - L = 20
9 Correct 122 ms 12428 KB Output is correct - L = 30
10 Correct 106 ms 12428 KB Output is correct - L = 20
11 Correct 86 ms 12428 KB Output is correct - L = 2
12 Correct 232 ms 12428 KB Output is correct - L = 20
13 Correct 81 ms 12428 KB Output is correct - L = 29
14 Correct 68 ms 12428 KB Output is correct - L = 2
# Verdict Execution time Memory Grader output
1 Correct 86 ms 12428 KB Output is correct - L = 124
2 Correct 72 ms 12428 KB Output is correct - L = 122
3 Correct 75 ms 12428 KB Output is correct - L = 120
4 Correct 75 ms 12428 KB Output is correct - L = 120
5 Correct 78 ms 12428 KB Output is correct - L = 127
6 Correct 75 ms 12428 KB Output is correct - L = 124
7 Correct 78 ms 12428 KB Output is correct - L = 120
8 Correct 81 ms 12428 KB Output is correct - L = 120
9 Correct 72 ms 12428 KB Output is correct - L = 180
10 Correct 72 ms 12428 KB Output is correct - L = 180
11 Correct 92 ms 12428 KB Output is correct - L = 180
12 Correct 89 ms 12428 KB Output is correct - L = 120
13 Correct 265 ms 12428 KB Output is correct - L = 120
14 Correct 75 ms 12428 KB Output is correct - L = 121
15 Correct 72 ms 12428 KB Output is correct - L = 121
16 Correct 95 ms 12428 KB Output is correct - L = 152
17 Correct 109 ms 12428 KB Output is correct - L = 124
18 Correct 112 ms 12428 KB Output is correct - L = 180
19 Correct 72 ms 12428 KB Output is correct - L = 180
20 Correct 99 ms 12428 KB Output is correct - L = 120
21 Correct 122 ms 12428 KB Output is correct - L = 120
22 Correct 75 ms 12428 KB Output is correct - L = 180
23 Correct 72 ms 12428 KB Output is correct - L = 180
24 Correct 68 ms 12428 KB Output is correct - L = 180
# Verdict Execution time Memory Grader output
1 Correct 76 ms 12428 KB Output is correct - L = 124
2 Correct 79 ms 12428 KB Output is correct - L = 122
3 Correct 72 ms 12428 KB Output is correct - L = 120
4 Correct 92 ms 12428 KB Output is correct - L = 120
5 Correct 76 ms 12428 KB Output is correct - L = 127
6 Correct 82 ms 12428 KB Output is correct - L = 124
7 Correct 88 ms 12428 KB Output is correct - L = 120
8 Correct 82 ms 12428 KB Output is correct - L = 120
9 Incorrect 68 ms 12428 KB Output isn't correct - L = 180
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 12428 KB Output isn't correct - L = 124
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 12428 KB Output isn't correct - L = 124
2 Incorrect 76 ms 12428 KB Output isn't correct - L = 122
3 Incorrect 84 ms 12428 KB Output isn't correct - L = 120
4 Incorrect 75 ms 12428 KB Output isn't correct - L = 120
5 Incorrect 78 ms 12428 KB Output isn't correct - L = 127
6 Incorrect 79 ms 12428 KB Output isn't correct - L = 124
7 Incorrect 78 ms 12428 KB Output isn't correct - L = 120
8 Incorrect 115 ms 12428 KB Output isn't correct - L = 120
9 Incorrect 68 ms 12428 KB Output isn't correct - L = 180
10 Incorrect 75 ms 12428 KB Output isn't correct - L = 180
11 Incorrect 68 ms 12428 KB Output isn't correct - L = 180
12 Incorrect 82 ms 12428 KB Output isn't correct - L = 120
13 Incorrect 235 ms 12428 KB Output isn't correct - L = 120
14 Incorrect 84 ms 12428 KB Output isn't correct - L = 121
15 Incorrect 79 ms 12428 KB Output isn't correct - L = 121
16 Incorrect 95 ms 12428 KB Output isn't correct - L = 152
17 Incorrect 98 ms 12428 KB Output isn't correct - L = 124
18 Incorrect 109 ms 12428 KB Output isn't correct - L = 180
19 Incorrect 89 ms 12428 KB Output isn't correct - L = 180
20 Incorrect 98 ms 12428 KB Output isn't correct - L = 120
21 Incorrect 112 ms 12428 KB Output isn't correct - L = 120
22 Incorrect 79 ms 12428 KB Output isn't correct - L = 180
23 Incorrect 85 ms 12428 KB Output isn't correct - L = 180
24 Incorrect 79 ms 12428 KB Output isn't correct - L = 180