vector<int>clockwisePrint(vector<vector<int>>mat,intn,intm){vector<int>ret;inti=0;intj=0;intstartx=0;intstarty=0;intendx=n-1;intendy=m-1;while(startx<=endx&&starty<=endy){if(endy==starty){for(j=endy,i=startx;i<=endx;++i){ret.push_back(mat[i][j]);}returnret;}if(endx==startx){for(i=startx,j=starty;j<=endy;++j){ret.push_back(mat[i][j]);}returnret;}for(i=startx,j=starty;j<=endy;++j){ret.push_back(mat[i][j]);}for(j=endy,i=startx+1;i<=endx;++i){ret.push_back(mat[i][j]);}for(i=endx,j=endy-1;j>=starty;--j){ret.push_back(mat[i][j]);}for(j=starty,i=endx-1;i>startx;--i){ret.push_back(mat[i][j]);}startx++;starty++;endx--;endy--;}returnret;}