답안 #81690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
81690 2018-10-26T07:51:35 Z Saboon Cipele (COCI18_cipele) C++14
0 / 90
1000 ms 263168 KB
#include <iostream>
#include <sstream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 37;

int a[maxn], b[maxn];
int n, m;

int match[maxn];
bool visited[maxn];

vector <int> g[maxn];

bool dfs (int v) {
    if (visited[v])
        return false;
    visited[v] = true;
    for (auto u : g[v]) {
        if (match[u] == -1 or dfs (match[u])) {
            match[u] = v;
            return true;
        }
    }
    return false;
}

int maximum_matching() {
    memset (match, -1, sizeof match);
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        memset (visited, 0, sizeof visited);
        ret += dfs (i);
    }
    return ret;
}

void make_graph (int x) {
    for (int i = 1; i <= n; i++) {
        g[i].clear();
        for (int j = 1; j <= m; j++) {
            if (abs (a[i] - b[j]) <= x) {
                g[i].PB (j);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++)
        cin >> b[i];
    if (n > m) {
        for (int i = 1; i <= n; i++) {
            int tmp = a[i];
            a[i] = b[i];
            b[i] = tmp;
        }
        swap (n, m);
    }

    int lo = -1, hi = 1000 * 1000 * 1000;
    while (hi - lo > 1) {
        int mid = (hi + lo) >> 1;
        make_graph (mid);
        if (maximum_matching() == n)
            hi = mid;
        else
            lo = mid;
    }
    cout << hi << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 600 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 502 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 86 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 263168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 487 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 505 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 520 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -