标签:Madoka int ll Codeforces 一行 cin Competitions maxn include
Madoka and Underground Competitions
构造
在一行里,如果选定了其中一个位置是 \(X\),接下来就直接往左和往右每 \(k\) 个放置一个 \(X\) 就行了
每一行的初始位置根据一开始的那个 \(X\),斜着一个方向铺满,即可做到每一行都存在一个 \(X\)
. | X | . | . | . |
---|---|---|---|---|
. | . | X | . | . |
. | . | . | X | . |
. | . | . | . | X |
X | . | . | . | . |
例如以上的,不管 \(k\) 是多少,先做到每行都铺一个
同一列上,每 \(k\) 个出现一个 \(X\) 的要求,可以通过那一行的初始 \(X\) 放置过来
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <deque>
#include <stack>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
const ll maxn = 510;
const ll inf = 1e17 + 10;
char gra[maxn][maxn];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--)
{
int n, k, r, c;
cin >> n >> k >> r >> c;
for(int i=0; i<=n; i++)
for(int j=0; j<=n; j++)
gra[i][j] = '.';
for(int i=0; i<n; i++)
{
gra[r][c] = 'X';
for(int j=c; j<=n; j+=k) gra[r][j] = 'X';
for(int j=c; j>=1; j-=k) gra[r][j] = 'X';
r++;
c++;
if(c > n) c = 1;
if(r > n) r = 1;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
cout << gra[i][j];
}
cout << "\n";
}
}
return 0;
}
标签:Madoka,int,ll,Codeforces,一行,cin,Competitions,maxn,include 来源: https://www.cnblogs.com/dgsvygd/p/16651814.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。