三国游戏

传送门:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define P pair<int,int>
const int N=1e4;
const int mod=1e9+7;
void read(int &a)
{
    a=0;
    int d=1;
    char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch-'0';
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=a*10+ch-'0';
    a*=d;
}
void write(int x)
{
    if(x<0)
        putchar(45),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
int a[505][505];
int main()
{
    int n;
    read(n);
    for(re int i=1;i<=n;i++)
        for(re int j=i+1;j<=n;j++)
        {
            read(a[i][j]);
            a[j][i]=a[i][j];
        }
    int ans=0;
    for(re int i=1;i<=n;i++)
    {
        sort(a[i]+1,a[i]+n+1);
        ans=a[i][n-1]>ans?a[i][n-1]:ans;
    }
    puts("1");
    write(ans);
    return 0;
}
原文地址:https://www.cnblogs.com/acm1ruoji/p/10697087.html