답안 #1029188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029188 2024-07-20T13:36:45 Z lucri 시간이 돈 (balkan11_timeismoney) C++17
15 / 100
2000 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;
long long t[210],u[10010],v[10010],ti[10010],mo[10010],n,m,vmax=2000000000000000000,st,sm,p1,p2;
long long sumt,summ;
struct muchii{long long u,v,val,valt,valm;}a[10010];
long long tata(long long n)
{
    if(t[n]==n)return n;
    return t[n]=tata(t[n]);
}
bool comp(muchii a,muchii b)
{
    if(a.val!=b.val)return a.val<b.val;
    if(a.u!=b.u)return a.u<b.u;
    if(a.v!=b.v)return a.v<b.v;
    return a.valt<b.valt;
}
void calculeaza(long long v1,long long v2)
{
    for(long long i=0;i<n;++i)
        t[i]=i;
    for(long long i=1;i<=m;++i)
        a[i]={u[i],v[i],ti[i]*v1+mo[i]*v2,ti[i],mo[i]};
    sumt=summ=0;
    sort(a+1,a+m+1,comp);
    for(long long i=1;i<=m;++i)
    {
        if(tata(a[i].u)!=tata(a[i].v))
        {
            t[t[a[i].u]]=t[a[i].v];
            sumt+=a[i].valt;
            summ+=a[i].valm;
        }
    }
}
void scrie(long long v1,long long v2)
{
    for(long long i=0;i<n;++i)
        t[i]=i;
    for(long long i=1;i<=m;++i)
        a[i]={u[i],v[i],ti[i]*v1+mo[i]*v2,ti[i],mo[i]};
    sort(a+1,a+m+1,comp);
    for(long long i=1;i<=m;++i)
    {
        if(tata(a[i].u)!=tata(a[i].v))
        {
            t[t[a[i].u]]=t[a[i].v];
            cout<<a[i].u<<' '<<a[i].v<<'\n';
        }
    }
}
int main()
{
    cin>>n>>m;
    for(long long i=1;i<=m;++i)
        cin>>u[i]>>v[i]>>ti[i]>>mo[i];
    for(long long i=0;i<=1000;++i)
        for(long long j=0;j<=1000;++j)
        {
            calculeaza(i,j);
            if(sumt*summ<vmax)
            {
                st=sumt,sm=summ;
                vmax=sumt*summ;
                p1=i;
                p2=j;
            }
        }
    cout<<st<<' '<<sm<<'\n';
    scrie(1,1);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2035 ms 344 KB Time limit exceeded
2 Correct 618 ms 436 KB Output is correct
3 Correct 933 ms 344 KB Output is correct
4 Execution timed out 2058 ms 348 KB Time limit exceeded
5 Execution timed out 2044 ms 344 KB Time limit exceeded
6 Execution timed out 2009 ms 344 KB Time limit exceeded
7 Execution timed out 2051 ms 856 KB Time limit exceeded
8 Execution timed out 2040 ms 1112 KB Time limit exceeded
9 Correct 644 ms 440 KB Output is correct
10 Incorrect 1639 ms 440 KB Output isn't correct
11 Incorrect 1063 ms 440 KB Output isn't correct
12 Execution timed out 2063 ms 348 KB Time limit exceeded
13 Execution timed out 2019 ms 344 KB Time limit exceeded
14 Execution timed out 2037 ms 344 KB Time limit exceeded
15 Execution timed out 2017 ms 344 KB Time limit exceeded
16 Execution timed out 2051 ms 604 KB Time limit exceeded
17 Execution timed out 2074 ms 604 KB Time limit exceeded
18 Execution timed out 2049 ms 344 KB Time limit exceeded
19 Execution timed out 2020 ms 1112 KB Time limit exceeded
20 Execution timed out 2067 ms 1116 KB Time limit exceeded