# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
228191 | 2020-04-30T07:34:03 Z | urd05 | 시간이 돈 (balkan11_timeismoney) | C++14 | 2000 ms | 640 KB |
#include <bits/stdc++.h> using namespace std; int n,m; struct Edge { int s,e,t,c; }; Edge edge[10000]; int one,two; bool comp(Edge a,Edge b) { return one*a.t+two*a.c<one*b.t+two*b.c; } int p[200]; int find(int a) { if (p[a]<0) { return a; } p[a]=find(p[a]); return p[a]; } void merge(int a,int b) { a=find(a); b=find(b); if (a==b) { return; } p[b]=a; } int main(void) { scanf("%d %d\n",&n,&m); for(int i=0;i<m;i++) { scanf("%d %d %d %d\n",&edge[i].s,&edge[i].e,&edge[i].t,&edge[i].c); } int opt1=-1; int opt2=-1; long long ret1=1e6; long long ret2=1e6; for(int i=0;i<256*n;i++) { for(int j=0;j<256*n;j++) { one=i; two=j; sort(edge,edge+m,comp); memset(p,-1,sizeof(p)); long long tsum=0; long long csum=0; for(int k=0;k<m;k++) { if (find(edge[k].s)!=find(edge[k].e)) { merge(edge[k].s,edge[k].e); tsum+=edge[k].t; csum+=edge[k].c; } } if (tsum*csum<ret1*ret2) { opt1=i; opt2=j; ret1=tsum; ret2=csum; } } } printf("%d %d\n",ret1,ret2); one=opt1; two=opt2; sort(edge,edge+m,comp); memset(p,-1,sizeof(p)); for(int i=0;i<m;i++) { if (find(edge[i].s)!=find(edge[i].e)) { merge(edge[i].s,edge[i].e); printf("%d %d\n",edge[i].s,edge[i].e); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2094 ms | 384 KB | Time limit exceeded |
2 | Execution timed out | 2069 ms | 256 KB | Time limit exceeded |
3 | Execution timed out | 2076 ms | 256 KB | Time limit exceeded |
4 | Execution timed out | 2084 ms | 256 KB | Time limit exceeded |
5 | Execution timed out | 2082 ms | 256 KB | Time limit exceeded |
6 | Execution timed out | 2098 ms | 256 KB | Time limit exceeded |
7 | Execution timed out | 2089 ms | 384 KB | Time limit exceeded |
8 | Execution timed out | 2072 ms | 640 KB | Time limit exceeded |
9 | Execution timed out | 2086 ms | 256 KB | Time limit exceeded |
10 | Execution timed out | 2088 ms | 256 KB | Time limit exceeded |
11 | Execution timed out | 2086 ms | 384 KB | Time limit exceeded |
12 | Execution timed out | 2076 ms | 384 KB | Time limit exceeded |
13 | Execution timed out | 2088 ms | 256 KB | Time limit exceeded |
14 | Execution timed out | 2075 ms | 256 KB | Time limit exceeded |
15 | Execution timed out | 2089 ms | 256 KB | Time limit exceeded |
16 | Execution timed out | 2078 ms | 384 KB | Time limit exceeded |
17 | Execution timed out | 2083 ms | 384 KB | Time limit exceeded |
18 | Execution timed out | 2078 ms | 384 KB | Time limit exceeded |
19 | Execution timed out | 2089 ms | 640 KB | Time limit exceeded |
20 | Execution timed out | 2088 ms | 640 KB | Time limit exceeded |