CF1179B Tolik and His Uncle
Posted lcxer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1179B Tolik and His Uncle相关的知识,希望对你有一定的参考价值。
codeforces
很有意思的构造题,自己并没想到
构造方法就是每次从一列的第一个连向最后一列的最后一个,然后不断交叉去连。
连完这两列后再往内走一个,以此类推
代码:
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define rg register
void read(int &x)
char ch;bool ok;
for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
const int maxn=1e6+10,inf=1e6;
int n,m,x,y;
int main()
read(n),read(m);x=1,y=1;
int l=1,r=m;
while(l<=r)
if(l==r)
for(rg int i=1;i<=n/2;i++)
printf("%d %d\\n",i,l);
printf("%d %d\\n",n-i+1,r);
if(n&1)printf("%d %d\\n",n/2+1,l);
else
for(rg int i=1;i<=n;i++)
printf("%d %d\\n",i,l);
printf("%d %d\\n",n-i+1,r);
l++,r--;
以上是关于CF1179B Tolik and His Uncle的主要内容,如果未能解决你的问题,请参考以下文章
CF-1362B. Johnny and His Hobbies
CF-1362B. Johnny and His Hobbies
CF776B Sherlock and his girlfriend
CF&&CC百套计划2 CodeChef December Challenge 2017 Chef And his Cake