首页 > 其他分享 >ZOJ4116 Game on a Graph(图+博弈论)

ZOJ4116 Game on a Graph(图+博弈论)

时间:2023-02-04 11:02:55浏览次数:55  
标签:Graph scanf t1 Game str printf else ZOJ4116 lld


题目连接:​​点击这里​

给出n个点m条边的图,k个人做游戏。分为两队,每次给图取掉一条边,若这这次行动后图不连通了,这个队就赢了,输出赢的队伍。

只要你能保证最低联通量,就是n-1就行,过了n-1则是作失败。

AC代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t,n,i,u,v,a,b,t1;
char str[210000];
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
scanf("%s",str);
scanf("%lld %lld",&u,&v);
for(i=0; i<=v-1; i++)
{
scanf("%lld %lld",&a,&b);
}
t1=v-u+1;
if(t1>0)
{
if(str[t1%n]=='1')
{
printf("2\n");
}
else if(str[t1%n]=='2')
{
printf("1\n");
}
}
else if(t1<=0)
{
if(str[0]=='1')
{
printf("2\n");
}
else if(str[0]=='2')
{
printf("1\n");
}
}
}
return 0;
}

 

标签:Graph,scanf,t1,Game,str,printf,else,ZOJ4116,lld
From: https://blog.51cto.com/u_15952369/6036930

相关文章

  • 使用graphviz图形化展示路径(决策树用到此库)
    问题:当出现错误graphviz.backend.execute.ExecutableNotFound:failedtoexecuteWindowsPath('dot'),makesuretheGraphvizexecutablesareonyoursystems'PATH......
  • GameFrameWork调研
     自上而下对应  Config提供了全局配置的读写功能,可用,但是没有意义,因为直接用1个全局静态类,直接读写就好了,更高效方便。而二进制功能需要的话,用scripObject方式也......
  • POJ 1733 Parity game (路径压缩并查集+离散化)
    DescriptionNowandthenyouplaythefollowinggamewithyourfriend.Yourfriendwritesdownasequenceconsistingofzeroesandones.Youchooseacontinuous......
  • 2018南京Gym - 101981J - Prime Game(计数)
    第一个元素的素因子2:它能贡献的区间有[1,1],[1,2],……,[1,10]10个区间第一个元素的素因子3:它能贡献的区间有[1,1],[1,2],……,[1,10]10个区间当前sum=10+10第二个元素......
  • [LeetCode] 1145. Binary Tree Coloring Game
    Twoplayersplayaturnbasedgameonabinarytree.Wearegiventhe root ofthisbinarytree,andthenumberofnodes n inthetree. n isodd,andeach......
  • cf791 D. Toss a Coin to Your Graph...
    这题问给出一个有向图,问走k步,每次费用为路径上的最大值,最大值最小是多少这种minmax问题,首先想到二分,然后我们可以对这个答案进行二分然后观察一下,如果能走k步,那么说明去......
  • Google XSS Game
    XSSgame(xss-game.appspot.com)这是一款谷歌的XSS游戏,总共有6个级别Level1无需转义,直接编辑URL栏或者搜索框中都可以执行<script>alert(1)</script>Leve......
  • [LeetCode]Jump Game II
    QuestionGivenanarrayofnon-negativeintegers,youareinitiallypositionedatthefirstindexofthearray.Eachelementinthearrayrepresentsyourmaximu......
  • Awesome GameDev
    个人收集的与游戏开发相关的资源。 素材1. AI生成素材3D素材1. Devassets 设计像素1. 像素辅助利器:特效/粒子/流体/动画/节点编辑为一体SpriteMancer......
  • Good Bye 2022: 2023 is NEAR D. Koxia and Game(数据结构,图论,数学)
    题目链接:https://codeforces.com/problemset/problem/1770/D 大致题意:有三个数组,每个数组的长度为n,数组里面的每个数在(1-n)。现在,对于每一位上面的数,Mahiru可以去掉其中......