Submission #268017

# Submission time Handle Problem Language Result Execution time Memory
268017 2020-08-16T07:55:32 Z stefantaga timeismoney (balkan11_timeismoney) C++14
5 / 100
19 ms 640 KB
#include <bits/stdc++.h>

using namespace std;
struct wow
{
    int x,y,bani,timp;
}v[10005];
bool compare (wow a,wow b)
{
    return a.bani*a.timp<b.bani*b.timp;
}
int tata[205],sol[2005],q,rang[205],sumbani,sumtimp;
int parinte (int x)
{
    if (tata[x]!=x)
    {
        return parinte(tata[x]);
    }
    return x;
}
void uneste (int x,int y)
{
    x=parinte(x);
    y=parinte(y);
    if (rang[x]<rang[y])
    {
        tata[x]=y;
    }
    else
    if (rang[x]>rang[y])
    {
        tata[y]=x;
    }
    else
    {
        tata[x]=y;
        rang[y]++;
    }
}
int n,m,i;
int main()
{
    #ifdef HOME
    ifstream cin("timeismoney.in");
    ofstream cout("timeismoney.out");
    #endif // HOME
    cin>>n>>m;
    for (i=1;i<=m;i++)
    {
        cin>>v[i].x>>v[i].y>>v[i].bani>>v[i].timp;
    }
    sort (v+1,v+m+1,compare);
    for (i=1;i<=n;i++)
    {
        tata[i]=i;
        rang[i]=1;
    }
    for (i=1;i<=m;i++)
    {
        if (parinte(v[i].x)!=parinte(v[i].y))
        {
            uneste(v[i].x,v[i].y);
            sumbani=sumbani+v[i].bani;
            sumtimp=sumtimp+v[i].timp;
            sol[++q]=i;
        }
    }
    cout<<sumbani<<" "<<sumtimp<<'\n';
    for (i=1;i<=q;i++)
    {
        cout<<v[i].x<<" "<<v[i].y<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 4 ms 384 KB Output isn't correct
8 Incorrect 18 ms 640 KB Output isn't correct
9 Incorrect 1 ms 288 KB Output isn't correct
10 Incorrect 1 ms 384 KB Output isn't correct
11 Incorrect 1 ms 384 KB Output isn't correct
12 Incorrect 1 ms 384 KB Output isn't correct
13 Incorrect 1 ms 384 KB Output isn't correct
14 Incorrect 1 ms 384 KB Output isn't correct
15 Incorrect 1 ms 384 KB Output isn't correct
16 Incorrect 4 ms 384 KB Output isn't correct
17 Incorrect 4 ms 384 KB Output isn't correct
18 Incorrect 4 ms 384 KB Output isn't correct
19 Incorrect 19 ms 640 KB Output isn't correct
20 Incorrect 18 ms 640 KB Output isn't correct