답안 #231145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231145 2020-05-12T21:40:25 Z summitwei 시간이 돈 (balkan11_timeismoney) C++17
40 / 100
18 ms 640 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define INF 0x3f3f3f3f
#define MOD 30013
#define f first
#define s second
#define pb push_back

#define FOR(i, a, b) for(int i=a; i<=b; ++i)
#define F0R(i, a) for(int i=0; i<a; ++i)

#define MN 10005
int n, m;
pair<int, pii> ree[MN];

int dsu[MN];
int fd(int x){
    if(dsu[x] < 0) return x;
    return dsu[x]=fd(dsu[x]);
}
bool jn(int x, int y){
    x = fd(x); y = fd(y);
    if(x == y) return false;
    if(dsu[x] > dsu[y]) swap(x, y);
    dsu[x] += dsu[y];
    dsu[y] = x;
    return true;
}
vpii used;

int main(){
    cin >> n >> m;
    F0R(i, m){
        cin >> ree[i].s.f >> ree[i].s.s >> ree[i].f >> ree[i].f;
    }
    sort(ree, ree+m);
    F0R(i, n) dsu[i] = -1;
    int tot = 0;
    F0R(i, m){
        if(jn(ree[i].s.f, ree[i].s.s)){
            tot += ree[i].f;
            used.pb(ree[i].s);
        }
    }
    cout << tot << " " << tot << "\n";
    for(auto u : used) cout << u.f << " " << u.s << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 9 ms 384 KB Output is correct
8 Correct 18 ms 640 KB Output is correct
9 Incorrect 4 ms 384 KB Output isn't correct
10 Incorrect 4 ms 384 KB Output isn't correct
11 Incorrect 4 ms 384 KB Output isn't correct
12 Incorrect 5 ms 384 KB Output isn't correct
13 Incorrect 5 ms 256 KB Output isn't correct
14 Incorrect 5 ms 384 KB Output isn't correct
15 Incorrect 5 ms 384 KB Output isn't correct
16 Incorrect 7 ms 384 KB Output isn't correct
17 Incorrect 7 ms 384 KB Output isn't correct
18 Incorrect 7 ms 384 KB Output isn't correct
19 Incorrect 17 ms 640 KB Output isn't correct
20 Incorrect 18 ms 640 KB Output isn't correct