首页 > 其他分享 >Cells Arrangement

Cells Arrangement

时间:2024-07-01 09:58:46浏览次数:1  
标签:int Cells IOS cin long Arrangement include

链接:https://www.luogu.com.cn/problem/CF1968E
题目:

有点像八皇后问题的条件
有一个重要的点就是明确上限:2*(N-1)所以应该是0~2n-2

思路就是选(1,1)和(1,2)然后剩下的点从(n,n)开始沿对角线往(1,1)放就行
代码:

#define _CRT_SECURE_NO_WARNINGS 
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<sstream>
#include<string>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<map>
#include<queue>
#include<limits.h>
#include<climits>
#include<fstream>
#include<stack>
#define IOS ios::sync_with_stdio(false), cin.tie(0) ,cout.tie(0)
using namespace std;
typedef long long ll;
const int N = 1e3 + 10;
int a[N][N];
vector<int>dist;

int main()
{
	IOS;
	int t; cin >> t;
	while (t--)
	{
		memset(a, -1, sizeof(a));
		int n; cin >> n;
		if (n == 1)
		{
			cout << "1 1\n\n";
		}
		else if(n==2)
		{
			cout << "1 1\n1 2\n\n";
		}
		else
		{
			cout << "1 1\n1 2\n";
			for (int i = 0; i < n - 2; i++)cout << n - i << ' ' << n - i << '\n';
			cout << '\n';
		}
	}

	return 0;
}

标签:int,Cells,IOS,cin,long,Arrangement,include
From: https://www.cnblogs.com/zzzsacmblog/p/18277416

相关文章

  • E. Cells Arrangement
    原题链接题解集合内元素最大不超过\(2n-1\),最小不小于\(1\)如果按对角线排列,则可以得到所有偶数,把其中一颗棋子往旁边移,可以得到所有奇数code#include<bits/stdc++.h>usingnamespacestd;intmain(){intt;cin>>t;while(t--){intn;......
  • CF1968E.Cells Arrangement-构造(给个和题解不同的做法)
    link:https://codeforces.com/problemset/problem/1968/E题意:需要构造一个\(n\timesn\)的棋盘,在上面放\(n\)枚棋子,设集合\(\mathcal{H}\)表示两两之间曼哈顿距离构成的集合,要让\(|\mathcal{H}|\)最大。给出放棋子的方案。首先说说题解的做法…考虑把距离为奇数和偶数的......
  • Aspose Cells 单元格 格式
    Aspose单元格格式编号///<summary>///单元格样式编号///0GeneralGeneral///1Decimal0///2Decimal0.00///3Decimal#,##0///4Decimal#,##0.00///5Currency$#,##0;$-#,##0///6Currency$#,##0;[Red]$-#,##0///7Currency$#,##0.00;$-#,#......
  • CodeForces 838D Airplane Arrangements
    洛谷传送门CF传送门考虑加入第\(n+1\)个位置,这样座位构成了一个环。每个位置被覆盖的概率相等,为\(\frac{m}{n+1}\),然后算出概率再乘方案数就行了。code//Problem:D.AirplaneArrangements//Contest:Codeforces-IndiaHacks2ndElimination2017(unofficial,......
  • [945] Replacing a string in all cells of a Pandas DataFrame
    ToreplaceastringinallcellsofaPandasDataFrame,wecanusethe str.replace()method,whichallowsustoperformstringreplacementsoneachelementofacolumn. Hereisanexample:importpandasaspd#CreateasampleDataFramedata={'Co......
  • 将CSS中的cellpadding和cellspacing设置为?
    内容来自DOChttps://q.houxu6.top/?s=将CSS中的cellpadding和cellspacing设置为?在HTML表格中,可以使用CSS设置cellpadding和cellspacing属性,如下所示:<style>table{cellspacing:1;cellpadding:1;}</style><table></table>这样就可以使用CS......
  • CF367C Sereja and the Arrangement of Numbers
    这题首先上来会发现题目中的很多信息都是假的,核心就是问要构造一个\(x\)个点的完全图至少要多长的序列我们把序列中相邻的两个元素看作图上的一条边,则可以把问题转化为:给一个\(x\)个点的完全图,问至少要走多长的路径才可以遍历图中的所有边至少一次简单讨论下会发现当\(x\)为奇数......
  • CF908D New Year and Arbitrary Arrangement 题解
    NewYearandArbitraryArrangement思路:期望题果然还是恶心呀!我们设\(f[i][j]\)表示当串中有\(i\)个\(a\)和\(j\)个\(ab\)时的方案数。为了方便,设\(A=\dfrac{P_a}{P_a+P_b},B=\dfrac{P_b}{P_a+P_b}\)。显然,可以这样转移:\[f[i][j]=f[i+1][j]\timesA+f[i][i+j]\ti......
  • 题解 P9695【[GDCPC2023] Traveling in Cells】
    显然,询问的答案即为\(x\)所在的极长的满足颜色均在\(\mathbb{A}\)内的连续段的权值和。如果我们能维护对颜色的单点修改,以及求出某个位置所在极长连续段的左右端点\(l,r\),只需要树状数组即可求出答案。一个朴素的想法是对每种颜色开一棵线段树,单点修改是平凡的,极长连续段左......
  • String Rearrangement in Phantom
    先考虑一个\(O(nq)\)的暴力,令\(s_{1}=S[l_{1},r_{1}],s_{2}=S[l_{2},r_{2}]\),令\(t=\operatorname{rev}(s_{2})\),则我们仅需求\(s_{1}=A+B+C,t=\operatorname{rev}(A)+B+\operatorname{rev}(C)\)的数量,对于每一个前缀和后缀求出其翻转是否与其相等即可,这个可以通过\(\text{......