Studying Father's luogu blog

Studying Father's luogu blog

从零至灵,由壹达意

题解 CF1173B 【Nauuo and Chess】

posted on 2019-06-08 02:23:17 | under 题解 |

Unofficial Solution to this contest also available in Studying Father's Blog.


一种构造方式是这样的:将前 $ \left\lfloor\frac n 2\right\rfloor+1 $ 个棋子按编号顺序从左往右放在第一行,剩下的棋子按编号顺序从上往下放在最后一列。(也就是摆成L形)

事实上,一切满足 $ r_i+c_i=i+1 $ 的方案都是可行解。证明可以参考官方题解的思路,这里略去。

#include <cstdio>
#include <algorithm>
using namespace std;
struct node
{
 int r,c;
}a[1005];
int main()
{
 int n;
 scanf("%d",&n);
 a[1].r=a[1].c=1;
 int mid=n/2+1;
 printf("%d\n",mid);
 for(int i=1;i<=mid;i++)
  printf("1 %d\n",i);
 for(int i=mid+1;i<=n;i++)
  printf("%d %d\n",i-mid+1,mid);
 return 0;
}