Submission #123695

# Submission time Handle Problem Language Result Execution time Memory
123695 2019-07-02T04:38:06 Z 박상수(#3035) Meetings (JOI19_meetings) C++14
29 / 100
2000 ms 1912 KB
#include "meetings.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

vector <pii> E;

void solve(vector <int> &X) {
    if(szz(X) <= 1) return;
    random_shuffle(all(X));
    int rt = X[0], m = szz(X);
    vector <vector<int> > V;
    vector <int> w; w.pb(X[1]); V.pb(w);
    int chk[2020] = {}; chk[X[0]] = chk[X[1]] = 1;
    for(int i=2;i<m;i++) {
        int a = X[i];
        if(chk[a]) continue;
        int l = szz(V);
        vector <int> ord;
        rep(j, l) ord.pb(j);
        sort(all(ord), [&](int x, int y) { return szz(V[x]) > szz(V[y]); });
        int f = -1;
        for(int e : ord) {
            int b = V[e][0];
            int c = Query(rt, a, b);
            if(c != rt) {
                V[e].pb(a); chk[a] = 1;
                if(chk[c] == 0) {
                    V[e].pb(c); chk[c] = 1;
                }
                for(int a=0;a<szz(V[e]);a++) if(V[e][a] == c) {
                    swap(V[e][a], V[e][0]);
                    break;
                }
                f = e;
                break;
            }
        }
        if(f == -1) {
            vector <int> w; w.pb(a); V.pb(w);
            chk[a] = 1;
        }
    }
    for(auto v : V) {
        E.pb(pii(rt, v[0]));
        solve(v);
    }
}

void Solve(int N) {
    vector <int> L;
    for(int i=0;i<N;i++) L.pb(i);
    solve(L);
    for(pii e : E) {
        if(e.Fi > e.Se) swap(e.Fi, e.Se);
        Bridge(e.Fi, e.Se);
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 3 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 28 ms 1020 KB Output is correct
28 Correct 20 ms 1016 KB Output is correct
29 Correct 29 ms 1176 KB Output is correct
30 Correct 38 ms 1300 KB Output is correct
31 Correct 23 ms 1016 KB Output is correct
32 Correct 36 ms 1400 KB Output is correct
33 Correct 40 ms 1264 KB Output is correct
34 Correct 52 ms 1912 KB Output is correct
35 Correct 59 ms 1912 KB Output is correct
36 Correct 17 ms 760 KB Output is correct
37 Correct 10 ms 504 KB Output is correct
38 Correct 11 ms 504 KB Output is correct
39 Correct 11 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 1520 KB Time limit exceeded
2 Halted 0 ms 0 KB -