Submission #6144

# Submission time Handle Problem Language Result Execution time Memory
6144 2014-06-20T11:54:31 Z gs13068 한자 끝말잇기 (JOI14_kanji) C++
0 / 100
215 ms 12436 KB
#include "Annalib.h"
#include<algorithm>

static long long D[300][300];
static long long D2[300][300];
static long long G[60];

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<K;i++)
  {
    for(j=0;j<Q;j++)G[j]=D2[S[j]][T[j]]-D2[S[j]][A[U[i]]]-D2[B[U[i]]][T[j]];
    std::sort(G,G+Q);
    j=std::lower_bound(G,G+Q,C[U[i]])-G;
    for(k=0;k<6;k++)Tap((j>>k)&1);
  }
  for(i=0;i<K;i++)for(j=i+1;j<K;j++)
  {
    for(k=0;k<Q;k++)G[k]=D2[B[U[i]]][T[k]]-D2[B[U[j]]][T[k]];
    std::sort(G,G+Q);
    k=std::lower_bound(G,G+Q,C[U[j]]-C[U[i]])-G;
    for(l=0;l<6;l++)Tap((k>>l)&1);
  }
}
#include "Brunolib.h"
#include<algorithm>

static long long D[300][300];
static int V[300][300];
static std::pair<long long,int> G[60];
static int Y[60];

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,p;
  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;
  }

  for(i=0;i<Q;i++)Y[i]=K;
  p=0;
  for(i=0;i<K;i++)
  {
    for(j=0;j<Q;j++)
    {
      G[j].first=D[S[j]][T[j]]-D[S[j]][A[U[i]]]-D[B[U[i]]][T[j]];
      G[j].second=j;
    }
    std::sort(G,G+Q);
    j=0;
    for(k=0;k<6;k++)j|=X[p++]<<k;
    for(k=j;k<Q;k++)if(Y[G[k].second]==K)Y[G[k].second]=i;
  }
  for(i=0;i<K;i++)for(j=i+1;j<K;j++)
  {
    for(k=0;k<Q;k++)
    {
      G[k].first=D[B[U[i]]][T[k]]-D[B[U[j]]][T[k]];
      G[k].second=k;
    }
    std::sort(G,G+Q);
    k=0;
    for(l=0;l<6;l++)k|=X[p++]<<l;
    for(l=k;l<Q;l++)if(Y[G[k].second]==i)Y[G[k].second]=j;
  }
  for(i=0;i<Q;i++)
  {
    if(Y[i]==K)answer(S[i],T[i]);
    else
    {
      answer(S[i],A[U[Y[i]]]);
      Answer(U[Y[i]]);
      answer(B[U[Y[i]]],T[i]);
    }
    Answer(-1);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 72 ms 12436 KB Output is correct - L = 90
2 Correct 78 ms 12436 KB Output is correct - L = 90
3 Correct 75 ms 12436 KB Output is correct - L = 90
4 Incorrect 81 ms 12436 KB Output isn't correct - Wrong Answer [9]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 12436 KB Output isn't correct - Wrong Answer [9]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 12436 KB Output isn't correct - Wrong Answer [9]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 12436 KB Output isn't correct - Wrong Answer [9]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 12436 KB Output isn't correct - Wrong Answer [9]
2 Incorrect 75 ms 12436 KB Output isn't correct - Wrong Answer [9]
3 Incorrect 72 ms 12436 KB Output isn't correct - L = 90
4 Incorrect 68 ms 12436 KB Output isn't correct - L = 90
5 Incorrect 72 ms 12436 KB Output isn't correct - Wrong Answer [9]
6 Incorrect 79 ms 12436 KB Output isn't correct - Wrong Answer [9]
7 Incorrect 79 ms 12436 KB Output isn't correct - L = 90
8 Incorrect 76 ms 12436 KB Output isn't correct - L = 90
9 Incorrect 75 ms 12436 KB Output isn't correct - Wrong Answer [9]
10 Incorrect 72 ms 12436 KB Output isn't correct - Wrong Answer [9]
11 Incorrect 68 ms 12436 KB Output isn't correct - Wrong Answer [9]
12 Incorrect 89 ms 12436 KB Output isn't correct - L = 90
13 Incorrect 215 ms 12436 KB Output isn't correct - L = 90
14 Incorrect 81 ms 12436 KB Output isn't correct - Wrong Answer [9]
15 Incorrect 72 ms 12436 KB Output isn't correct - Wrong Answer [9]
16 Incorrect 92 ms 12436 KB Output isn't correct - Wrong Answer [9]
17 Incorrect 96 ms 12436 KB Output isn't correct - Wrong Answer [9]
18 Incorrect 95 ms 12436 KB Output isn't correct - Wrong Answer [9]
19 Incorrect 82 ms 12436 KB Output isn't correct - Wrong Answer [9]
20 Incorrect 82 ms 12436 KB Output isn't correct - L = 90
21 Incorrect 99 ms 12436 KB Output isn't correct - L = 90
22 Incorrect 72 ms 12436 KB Output isn't correct - Wrong Answer [9]
23 Incorrect 68 ms 12436 KB Output isn't correct - Wrong Answer [9]
24 Incorrect 68 ms 12436 KB Output isn't correct - Wrong Answer [9]