“三国游戏” 题解

· · 个人记录

这题有意思,让我想起了---红警

额,跑题了,赶紧切入正题......

这题我不解释了,看代码。

include<iostream>

include<algorithm>

define f(i,l,r) for(i=(l);i<=(r);i++)

using namespace std;

const int MAXN=505;

int a[MAXN][MAXN],n;
int main()

{

ios::sync_with_stdio(false);
int i,j,max1,max2,ans=0;
cin>>n;
f(i,1,n){
    max1=max2=0;
    f(j,i+1,n){
        cin>>a[i][j];
        a[j][i]=a[i][j];
    }
    f(j,1,n){
        if(a[i][j]>max1){
            max2=max1;
            max1=a[i][j];
        }
        else if(a[i][j]>max2){
            max2=a[i][j];
        }
    }
    ans=max(ans,max2);
}
cout<<1<<endl<<ans<<endl;
return 0;

}


看懂的大佬,点个赞再走呗。
  ▄█▀█●