首页 > 其他分享 >杭电9-Just another board game

杭电9-Just another board game

时间:2022-11-07 13:07:04浏览次数:70  
标签:maxx int ll 杭电 game another ans include lld


​传送门​

杭电9-Just another board game_最小化

题意:

给你一个杭电9-Just another board game_最小化_02的网格,每个格子里有其相应的权重,最初有一个棋子在杭电9-Just another board game_i++_03上,棋子最终所在的位置为最终值,a想要最大化这个值,b要最小化这个值。

思路:

从整场比赛来看,如果某人不是最后一次移动棋子的那个人,那么他应该考虑的是:尽量让另一个人下次所能移动的最小/最大值最大/最小
例如,如果是b最后一次移动棋子(k为偶数),b想要最小化这个值,而a则需要将棋子移动到每一列的最小值最大的那一列,如果是a最后一次移动棋子(k为奇数),道理和上面差不多,最后只需要将用此方法得到的答案与(1,1)的值进行比对即可。

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<math.h>
#include<vector>
using namespace std;
#define ll long long
ll maxx_n[100010];
ll maxx_m[100010];

int main()
{
int t;
cin>>t;
while(t--)
{
int n,m;
ll k;
ll s = 0;
scanf("%d%d%lld",&n,&m,&k);
memset(maxx_n,0,sizeof(maxx_n));
memset(maxx_m,0x3f3f3f3f,sizeof(maxx_m));
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
ll op;
scanf("%lld",&op);
if(i == 0 && j == 0)s = op;
maxx_n[i] = max(maxx_n[i], op);
maxx_m[j] = min(maxx_m[j], op);
}
}
if(k == 1)
{
printf("%lld\n", maxx_n[0]);
}
else if(k == 2)
{
ll ans = 0;
for(int i = 0; i < m; i++)ans = max(maxx_m[i], ans);
printf("%lld\n",max(ans, s));
}
else if(k%2)
{
ll ans = 0x3f3f3f3f;
for(int i = 0; i < n; i++)ans = min(ans, maxx_n[i]);
printf("%lld\n",max(ans, s));
}
else if(k%2==0)
{
ll ans = 0;
for(int i = 0; i < m; i++)ans = max(maxx_m[i], ans);
printf("%lld\n",max(ans, s));
}
}
}


标签:maxx,int,ll,杭电,game,another,ans,include,lld
From: https://blog.51cto.com/u_15866543/5828908

相关文章

  • 45. Jump Game II
    Youaregivena 0-indexed arrayofintegers nums oflength n.Youareinitiallypositionedat nums[0].Eachelement nums[i] representsthemaximumleng......
  • 55. Jump Game
    Youaregivenanintegerarray nums.Youareinitiallypositionedatthearray's firstindex,andeachelementinthearrayrepresentsyourmaximumjumpleng......
  • 题解 [ABC259Ex] Yet Another Path Counting
    首先,每种颜色互不干扰,因此考虑对每种颜色统计答案。有两种解法:枚举起始格子\((x,y)\)和结尾格子\((z,w)\),由组合数易知共有\(\binom{z-x+w-y}{z-x}\)种路径。时间......
  • 基于gamebased算法的动态频谱访问matlab仿真
    目录一、理论基础二、核心程序三、测试结果一、理论基础随着越来越多的新型无线应用,对频谱资源的需求越来越大。在这种情况下,这是举世公认的认知无线电的出现已经成......
  • Codeforces Round #832 (Div. 2) C. Swap Game (博弈论)
    https://codeforces.com/contest/1747/problem/CC.SwapGame题目大意:给定一个长度为n的数组a,每次只要当我想动但是发现a[1]==0的时候我就输了要么就是我每次把a[1]......
  • Google Game Service 接入指南
    前言应用接入Game登录,接入过程中遇到各种卡流程的问题,首次接入Gamev2,发现Gamev2版本的调用时机无法自行控制,并且不能退出当前登录的账户。而旧版gamev1的api提供了退......
  • 基于gamebased算法的动态频谱访问matlab仿真
    目录一、理论基础二、核心程序三、测试结果一、理论基础随着越来越多的新型无线应用,对频谱资源的需求越来越大。在这种情况下,这是举世公认的认知无线电的出现已经成为......
  • 杭电多校补题
    题目100110021003100410051006100710081009101110121013​​Contest1​​Path​​Contest2​​\​​Contest3​​\\\​​Contest4​​\\\​​Contest5​​\\\​​Conte......
  • QSocketNotifier: Socket notifiers cannot be enabled or disabled from another(转)
    在使用Qt开发多线程、socket通讯功能时,遇到以下两个问题:QSocketNotifier:SocketnotifierscannotbeenabledordisabledfromanotherQObject:Cannotcreatechildr......
  • Git报错:Another git process seems to be running in this repository 解决方法
    Unabletocreate‘D:/xxx/.git/index.lock’:Fileexists.Anothergitprocessseemstoberunninginthisrepository,e.g.aneditoropenedby‘gitcommit’.......