Cod sursa(job #2328082)

Utilizator testEMTest Surse testEM Data 25 ianuarie 2019 13:04:08
Problema Arbore partial de cost minim Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.85 kb
#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;
}