CodeForces
来源:互联网 发布:今日影评表演者 知乎 编辑:程序博客网 时间:2024/06/06 02:52
点击打开链接
题意: 给你一个地图, 让你建n个岛,能否建成。能的话打印出一个建好的地图。
题解:构造,先判断能否建成,能的话直接构造,依次交替的建。
#include<iostream>#include<string>#include<stdio.h>#include<string.h>#include<map>#include<set>#include<queue>#include<math.h>#include<algorithm>#define ll long longusing namespace std;const int maxn=111;const int maxm=1e5+100;const int inf = 5000001;int ma[maxn][maxn];int main(){ int n,k; scanf("%d %d",&n,&k); int nn=n*n; if(nn%2==0) nn=nn/2; else nn=nn/2+1; if(k>nn) {printf("NO\n");return 0;} printf("YES\n"); for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ if(i%2==0){ if(j%2==0&&k) cout<<'L',k--; else cout<<'S'; }else{ if(j%2!=0&&k) cout<<'L',k--; else cout<<'S'; } }puts(""); } return 0;}
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- c++--静态成员变量
- 4559: [JLoi2016]成绩比较
- TextComponent
- 用PHP尝试RabbitMQ(amqp扩展)实现消息的发送和接收
- 用PHP尝试RabbitMQ(amqp扩展)实现消息的发送和接收
- CodeForces
- ubuntu安装memcached
- 归并排序
- jQuery easyui Session 超时返回登录页面
- JavaScript运算符优先级与结合性
- Http
- vitamio 小米pad 上无法播放问题
- linux部署tomact不能打开页面的情况
- MySQL EXPLAIN 命令详解学习