Pagini recente » Cod sursa (job #2440052) | Cod sursa (job #1425258) | Cod sursa (job #998565) | Cod sursa (job #1338957) | Cod sursa (job #2328082)
#include<fstream>
using namespace std;
ifstream in("apm.in");
ofstream out("apm.out");
int a[20001][20001];
/*
int rw(int n , int a[][20001])
{
for(int k=1;k<=n;k++)
for(int j=1;j<=n;j++)
for(int i=1;i<=n;i++)
{
}
}
*/
int main ()
{
int n,m,x,y,c,xmaxx=-1001,ymaxx=-1001,maxx=-1001,s=0;
in>>n>>m;
if(n==m)
{
for(int i=1;i<=m;i++)
{
in>>x>>y>>c;
a[x][y]=c;
if(c>maxx)
{
xmaxx==x;
ymaxx==y;
maxx=c;
}
s=s+c;
}
out<<s-maxx<<endl;
out<<n-1<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
if(a[i][j]!=0 and a[i][j]!=maxx)
out<<j<<" "<<i<<endl;
}
}
return 0;
}