Distributed Nonparametric Function Estimation: Optimal Rate of Convergence and Cost of Adaptation