Extremal problems for labelling of graphs and distance in digraphs