12 条题解
-
1RP++ (贪吃蛇) LV 8 @ 2021-02-25 12:31:38
#include<bits/stdc++.h> using namespace std; int n,m,dis[10002],a[502][502],ans; int main() { cin>>n; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { cin>>a[i][j]; a[j][i]=a[i][j]; } } for(int i=1;i<=n;i++) { sort(a[i]+1,a[i]+n+1); if(a[i][n-1]>ans) { ans=a[i][n-1]; } } cout<<"1"<<endl<<ans<<endl; return 0; }
-
12016-07-03 10:14:38@
var n,i,j,k,max,final:longint; m:array[0..500] of longint; a:array[0..500,0..500] of longint;
begin
readln(n);
for i:=1 to n do
for j:=i+1 to n do
begin
read(a[i,j]);
a[j,i]:=a[i,j];
end;for k:=1 to 2 do
for i:=1 to n do begin max:=1;
for j:=1 to n do
if a[i,j]>a[i,max] then max:=j;
if k=1 then a[i,max]:=0
else m[i]:=a[i,max] end;final:=m[1];
for i:=2 to n do if final<m[i] then final:=m[i];
writeln('1');
writeln(final);
end. -
02016-08-24 10:27:07@
在所有次大值中找最大值
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n,mo[501][501],sum,maxi[501],maxi2[501],maxii2[501],maxi3[501],han[4],robot[4];
bool b[501]={0};
int main()
{
freopen("sanguo.in","r",stdin);
freopen("sanguo.out","w",stdout);cin>>n;
for(int i=1;i<=n-1;i++)
{
for(int j=i+1;j<=n;j++)
{
cin>>sum;
mo[i][j]=mo[j][i]=sum;
}
}
for(int i=1;i<=n;i++)
{
long long maxii=-1;
for(int j=1;j<=n;j++)
{
if(i!=j && mo[i][j]>maxii)
{
maxii=mo[i][j];
maxi[i]=mo[i][j];
maxii2[i]=j;
}
}
}
for(int i=1;i<=n;i++)
{
long long maxii=-1;
for(int j=1;j<=n;j++)
{
if(i!=j && mo[i][j]>maxii && maxi[i]!=mo[i][j])
{
maxii=mo[i][j];
maxi2[i]=mo[i][j];
maxi3[i]=j;
}
}
}
long long maxii=-1,maxiii,maxiij;
for(int i=1;i<=n;i++)if(maxi2[i]>maxii)
{
maxii=maxi2[i];
}
cout<<"1"<<endl;
cout<<maxii<<endl;fclose(stdin);fclose(stdout);
} -
02016-08-08 18:17:41@
在所有次大值中找最大值
-
02015-12-21 17:19:45@
找出每组武将中默契值除最大值以外第二大的值,太水了。。。。。。
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[1000][1000],ans,maxx;int main()
{
//freopen("p.in","r",stdin);
//freopen("p.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n-1;i++)
{
for(int j=i;j<=n;j++)
{
if(i==j)
continue;
scanf("%d",&a[i][j]);
a[j][i]=a[i][j];
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]>a[i][maxx])
maxx=j;
}
a[i][maxx]=0;
for(int j=1;j<=n;j++)
{
ans=max(ans,a[i][j]);
}
maxx=0;
}
printf("1\n%d",ans);
return 0;
} -
02015-06-24 16:19:12@
当小涵选了第一个武将后,机器必将拿走与之配对的最大默契武将,于是小涵只能拿走与之配对的次大默契武将。如果次大默契武将与其他武将存在更高的默契,机器也会拿走。所以无论如何,小涵只能拿到一个武将与之配对的次大默契武将。找到每位武将配对的次大默契武将,输出每位武将次大配对默契值中最大的一个即可。人有必赢策略,不用考虑输出0的情况。
#include<stdio.h>
int main( )
{int s[501][501];
int i,j,n,max1=0,max2=0,maxans=0;for(i=0;i<=500;i++)
for(j=0;j<=500;j++)
s[i][j]=0;scanf("%d",&n);
for(i=1;i<=n-1;i++)
for(j=i+1;j<=n;j++)
{
scanf("%d",&s[i][j]);
s[j][i]=s[i][j];
}for(i=1;i<=n;i++)
{
max1=0;max2=0;for(j=1;j<=n;j++)
{
if(s[i][j]>max1) {max2=max1;max1=s[i][j];}
else if(s[i][j]>max2) max2=s[i][j];
}if(max2>maxans) maxans=max2;
}printf("1\n");
printf("%d",maxans);return 0;
} -
02015-03-29 12:01:36@
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<time.h>
#include<stdlib.h>
using namespace std;
int a[505][505];
int size;
int main(){
freopen("in.txt", "r", stdin);
int i, j;
cin >> size;
for (i = 0; i < size; i++){
for (j = i+1; j < size; j++){
cin >> a[i][j];
a[j][i] = a[i][j];
}
}
int ans = 0;
for (i = 0; i < size; i++){
int one=0,two=0;
for (j =0; j < size; j++){
int*k;
if (one>two)k = &two;
else k = &one;
if (a[i][j]>*k){
*k = a[i][j];
}
}
ans = max(min(one, two),ans);
}
cout << 1 << endl << ans << endl;
return 0;
} -
02014-10-08 21:04:44@
#include <iostream>
using namespace std;
int n,x[501][501],cigao[501];
int main()
{
cin >> n;
for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
{
cin >> x[i][j];
x[j][i]=x[i][j];
}
for (int i=1;i<=n;i++)
{
int max=1;
for (int j=2;j<=n;j++)
if(x[i][j]>x[i][max]) max=j;
x[i][max]=0;
for (int j=2;j<=n;j++)
if(x[i][j]>max) max=x[i][j];
cigao[i]=max;
}
int max=0;
for (int i=1;i<=n;i++)
if(cigao[i]>max) max=cigao[i];
cout<<1<<endl<<max<<endl;
//system("pause");
return 0;
} -
02014-05-04 18:13:56@
program a01;
var
n,j,i:longint;
max,max2:qword;
a:array[0..501,0..501] of qword;
begin
read(n);
for i := 1 to n do
begin
max:=0;
max2:=0;
for j := 1 to n do
begin
if j>i then
begin
read(a[i,j]);
a[j,i]:=a[i,j];
end;
if max<a[i,j] then
begin
max2:=j;
max:=a[i,j];
end;
end;
a[i,max2]:=0;
for j := 1 to n do
if a[i,0]<a[i,j] then a[i,0]:=a[i,j];
end;
max:=0;
for i := 1 to n do
if a[i,0]>max then max:=a[i,0];
writeln(1);
writeln(max);
end. -
02014-05-04 18:13:50@
program a01;
var
n,j,i:longint;
max,max2:qword;
a:array[0..501,0..501] of qword;
begin
read(n);
for i := 1 to n do
begin
max:=0;
max2:=0;
for j := 1 to n do
begin
if j>i then
begin
read(a[i,j]);
a[j,i]:=a[i,j];
end;
if max<a[i,j] then
begin
max2:=j;
max:=a[i,j];
end;
end;
a[i,max2]:=0;
for j := 1 to n do
if a[i,0]<a[i,j] then a[i,0]:=a[i,j];
end;
max:=0;
for i := 1 to n do
if a[i,0]>max then max:=a[i,0];
writeln(1);
writeln(max);
end. -
02013-11-30 20:32:19@
program a01;
var
n,j,i:longint;
max,max2:qword;
a:array[0..501,0..501] of qword;
begin
read(n);
for i := 1 to n do
begin
max:=0;
max2:=0;
for j := 1 to n do
begin
if j>i then
begin
read(a[i,j]);
a[j,i]:=a[i,j];
end;
if max<a[i,j] then
begin
max2:=j;
max:=a[i,j];
end;
end;
a[i,max2]:=0;
for j := 1 to n do
if a[i,0]<a[i,j] then a[i,0]:=a[i,j];
end;
max:=0;
for i := 1 to n do
if a[i,0]>max then max:=a[i,0];
writeln(1);
writeln(max);
end.有必胜的策略所以根本不会输,不用在意输出0的情况……没有很好的优化不过ac了
-
02013-10-02 15:07:51@
有必胜策略,玩家总能保证电脑取不到最大边,且玩家能取到的最优边一定是某个顶点的次大边
- 1
信息
- ID
- 1809
- 难度
- 3
- 分类
- (无)
- 标签
- 递交数
- 839
- 已通过
- 428
- 通过率
- 51%
- 被复制
- 16
- 上传者