zoukankan      html  css  js  c++  java
  • 洛谷1199 三国游戏

    原题链接

    因为电脑始终会把你选择的武将的同行默契最大的配对武将选走,所以你肯定不能配对出同行默契最大的武将。
    所以我们可以考虑退(da)而(li)求(cai)其(jie)次(lun),配对出每行次大中最大的那一对。
    然后不管电脑选择的武将是全部最大还是仅同行最大,你都可以破坏电脑的匹配。
    因为你是先手,电脑总是被动的,虽然你拿不到最大的,但你也可以让电脑也拿不到最大的,于是你配对的最大次大就是最后最大的了。
    上面纯属我的叽歪,更详细的证明可以看这位大佬的博客

    #include<cstdio>
    #include<algorithm>
    using namespace std;
    const int N = 510;
    int a[N][N];
    inline int re()
    {
    	int x = 0;
    	char c = getchar();
    	bool p = 0;
    	for (; c < '0' || c > '9'; c = getchar())
    		p |= c == '-';
    	for (; c >= '0' && c <= '9'; c = getchar())
    		x = x * 10 + c - '0';
    	return p ? -x : x;
    }
    inline int maxn(int x, int y)
    {
    	return x > y ? x : y;
    }
    int main()
    {
    	int i, j, ma = 0, n;
    	n = re();
    	for (i = 1; i <= n; i++)
    		for (j = i + 1; j <= n; j++)
    			a[i][j] = a[j][i] = re();
    	for (i = 1; i <= n; i++)
    	{
    		sort(a[i] + 1, a[i] + n + 1);
    		ma = maxn(ma, a[i][n - 1]);
    	}
    	printf("1
    %d", ma);
    	return 0;
    }
    
  • 相关阅读:
    注解之------@WebService
    注解之----@component,@controller,@service ,@repository简介
    Java 之 I/O
    标签之----@Override
    注解之----@Resource
    弹指之间 -- 简谱
    弹指之间 -- Prerequisites
    MVC5 + EF6 完整入门教程三
    MVC5 + EF6 入门完整教程二
    MVC5 + EF6 入门完整教程
  • 原文地址:https://www.cnblogs.com/Iowa-Battleship/p/9855388.html
Copyright © 2011-2022 走看看