题解——Codeforces Round #507 (based on Olympiad of Metropolises) T2(模拟)
T2还是模拟
枚举一下第一个放哪里
然后贪心的反转即可
虽然我也不会证,但是这题肯定有解qwq
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; int n,k,ans=0x3f3f3f3f,path[1200],midpath[1200],midans; int main(){ scanf("%d %d",&n,&k); for(int i=1;i<=k+1;i++){ int l=i,r=k+i; midans=1; midpath[1]=i; while(r<n){ midans++; l=r+1; r=l+2*k; // printf("%d %d\n",l,r); midpath[midans]=k+l; } if(midans<ans){ ans=midans; memcpy(path,midpath,sizeof(midpath) ); } } printf("%d\n",ans); for(int i=1;i<=ans;i++) printf("%d ",path[i]); return 0; }