답안 #6146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
6146 2014-06-20T14:01:55 Z gs13068 한자 끝말잇기 (JOI14_kanji) C++
0 / 100
239 ms 11732 KB
#include "Annalib.h"
#include<algorithm>

static long long D[300][300];
static long long G[60];
static int Y[60];

void Anna(int N,int M,int A[],int B[],long long C[],int Q,int S[],int T[],int K,int U[])
{
  long long val=0,mul=1;
  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++)
  {
    for(j=0;j<K;j++)if(i==U[j])break;
    if(j==K)D[A[i]][B[i]]=C[i];
  }
  for(i=0;i<N;i++)D[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];

  for(i=0;i<Q;i++)Y[i]=K;
  for(i=0;i<K;i++)
  {
    for(j=0;j<i;j++)
    {
      l=0;
      for(k=0;k<Q;k++)if(Y[k]==j)
      {
        G[l]=D[B[U[i]]][T[k]]-D[B[U[j]]][T[k]];
        if(G[l]<-C[U[i]]+C[U[j]])Y[k]=i;
        l++;
      }
      std::sort(G,G+l);
      k=std::lower_bound(G,G+l,-C[U[i]]+C[U[j]])-G;
      val+=k*mul;
      mul*=l;
    }
    l=0;
    for(k=0;k<Q;k++)if(Y[k]==K)
    {
      G[l]=D[S[k]][A[U[i]]]+D[B[U[i]]][T[k]]-D[S[k]][T[k]];
      if(G[l]<0)Y[k]=i;
      l++;
    }
    std::sort(G,G+l);
    k=std::lower_bound(G,G+1,-C[U[i]])-G;
    val+=k*mul;
    mul*=l;
  }
  while(val)
  {
    Tap(val&1);
    val>>=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[])
{
  long long val=0,mul=1;
  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<L;i++)
  {
    val+=X[i]*mul;
    mul<<=1;
  }
  for(i=0;i<Q;i++)Y[i]=K;
  for(i=0;i<K;i++)
  {
    for(j=0;j<i;j++)
    {
      l=0;
      for(k=0;k<Q;k++)if(Y[k]==j)
      {
        G[l].first=D[B[U[i]]][T[k]]-D[B[U[j]]][T[k]];
        G[l].second=k;
        l++;
      }
      std::sort(G,G+l);
      for(k=0;k<val%l;k++)Y[G[k].second]=i;
      val/=l;
    }
    l=0;
    for(k=0;k<Q;k++)if(Y[k]==K)
    {
      G[l].first=D[S[k]][A[U[i]]]+D[B[U[i]]][T[k]]-D[S[k]][T[k]];
      G[l].second=k;
      l++;
    }
    std::sort(G,G+l);
    for(k=0;k<val%l;k++)Y[G[k].second]=i;
    val/=l;
  }
  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);
  }
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, int*, int*, long long int*, int, int*, int*, int, int*, int, int*)':
Bruno.cpp:22:15: warning: unused variable 'p' [-Wunused-variable]
   int i,j,k,l,p;
               ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 11732 KB Output isn't correct - Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 11732 KB Output isn't correct - Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 11732 KB Output isn't correct - Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 11732 KB Output isn't correct - Wrong Answer [6]
2 Incorrect 62 ms 11732 KB Output isn't correct - Wrong Answer [6]
3 Runtime error 62 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Runtime error 55 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
5 Incorrect 55 ms 11732 KB Output isn't correct - Wrong Answer [8]
6 Incorrect 65 ms 11732 KB Output isn't correct - Wrong Answer [9]
7 Runtime error 55 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
8 Runtime error 68 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
9 Runtime error 62 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
10 Runtime error 58 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
11 Runtime error 58 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
12 Runtime error 55 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
13 Runtime error 239 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
14 Incorrect 62 ms 11732 KB Output isn't correct - Wrong Answer [8]
15 Runtime error 62 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
16 Runtime error 78 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
17 Runtime error 78 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
18 Runtime error 86 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
19 Runtime error 68 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
20 Runtime error 76 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
21 Runtime error 88 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
22 Runtime error 69 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
23 Runtime error 55 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)
24 Runtime error 62 ms 11732 KB Execution killed with signal 8 (could be triggered by violating memory limits)