Search for dijet resonances in proton-proton collisions at sqrt(s)=13TeV and constraints on dark matter and other models