Submission #84738

# Submission time Handle Problem Language Result Execution time Memory
84738 2018-11-17T04:40:50 Z kjh5678 None (KOI18_robot) C++14
0 / 100
75 ms 13944 KB
#if 01
#include <stdio.h>
#define MAX(x,y) ((x>y)?(x):(y))
int N, r1, r2;

typedef struct _idxarr
{
	int node;
	long long dist;
	_idxarr* next;
	_idxarr(){ node = dist = 0; next = (_idxarr*)0; };
	_idxarr(int a, long long b, _idxarr* c){ node = a; dist = b; next = c; }
}ia;

ia arr[100001];
long long dist[100001];
long long max[100001];
int visit[100001];

void input()
{
	scanf("%d %d %d", &N, &r1, &r2);
	for (int i = 1; i <= N; i++)
	{
		int x, y, v;
		scanf("%d%d%d", &x, &y, &v);
		arr[x].next = new ia(y, v, arr[x].next);

		arr[y].next = new ia(x, v, arr[y].next);
	}
}

void DFS(int node, long long d, long long m)
{
	dist[node] = d;
	max[node] = m;
	visit[node] = 1;
	for (ia* src = &arr[node]; src->next; src = src->next)
	{
		if (visit[src->next->node]) continue;
		DFS(src->next->node, d + src->next->dist, MAX(m, src->next->dist));
	}
}


int main()
{
	input();

	DFS(r1, 0, 0);

	printf("%ll", dist[r2] - max[r2]);
}

#endif

Compilation message

robot.cpp: In function 'int main()':
robot.cpp:52:34: warning: conversion lacks type at end of format [-Wformat=]
  printf("%ll", dist[r2] - max[r2]);
                                  ^
robot.cpp:52:34: warning: too many arguments for format [-Wformat-extra-args]
robot.cpp: In function 'void input()':
robot.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &N, &r1, &r2);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
robot.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 13944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 13944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 13944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 13944 KB Output isn't correct
2 Halted 0 ms 0 KB -