E - Gojou and Matrix Game

Posted thusloop

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E - Gojou and Matrix Game相关的知识,希望对你有一定的参考价值。

E - Gojou and Matrix Game
因为v[i][j]的值都不同 所以先找最大值,一定先手胜利(第二个人选了之后第一个人可以无限次选最大值)
之后在曼哈顿距离外的点一定不能赢
在曼哈顿距离内的找一点最大值(也一定赢)
……………………(不断去找 且要维护菱形的面积,可以用斜线去表示菱形)

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int inf=8e18;
const int maxn=2e5+100;
int n,k;
int f[2100][2100];

signed main()

	IOS
	int n,k;
	cin>>n>>k;
	priority_queue<tuple<int,int,int,int,int,int,int>>q;
	for(int i=1; i<=n; i++)
	
		for(int j=1; j<=n; j++)
		
			int x;
			cin>>x;
			q.push(x,i+j-k,i+j+k,i-j-k,i-j+k,i,j);
		
	
	auto now=q.top();
	q.pop();
	int x=get<5>(now);
	int y=get<6>(now);
	int nl=get<1>(now);
	int nr=get<2>(now);
	int nd=get<3>(now);
	int nu=get<4>(now);
	f[x][y]=1;
	while(!q.empty())
	
		auto now=q.top();
		q.pop();
		x=get<5>(now);
		y=get<6>(now);
		if(x+y>=nl&&x+y<=nr&&x-y>=nd&&x-y<=nu)
		
			//cout<<get<1>(now)<<" "<<get<2>(now)<<" "<<get<3>(now)<<" "<<get<4>(now)<<"\\n";
			nl=max(get<1>(now),nl);
			nr=min(get<2>(now),nr);
			nd=max(get<3>(now),nd);
			nu=min(get<4>(now),nu);
			f[x][y]=1;
		
	
	for(int i=1; i<=n; i++)
	
		for(int j=1; j<=n; j++)
		
			if(f[i][j])cout<<"M";
			else cout<<"G";
		
		cout<<"\\n";
	


以上是关于E - Gojou and Matrix Game的主要内容,如果未能解决你的问题,请参考以下文章

codeforces 842E. Nikita and game

[ AGC007 D ] Shik and Game

CF 1042 E. Vasya and Magic Matrix

CF 873C Strange Game On Matrix(贪心)

Codeforces Round #648 (Div. 2) A - Matrix Game

CF1350E Orac and Game of Life(BFS)