ログインしてください。
提出 #594025
ソースコード 拡げる
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define rep(i, n) FOR(i, 0, n - 1)
#define rep1(i, n) FOR(i, 1, n)
#define rrep(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define all(a) (a).begin(),(a).end()
#define PB push_back
using namespace std;
using ll = long long int;
using vb = vector<bool>;
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvll = vector<vll>;
using vvvi = vector<vvi>;
using vvvd = vector<vvd>;
using P = pair<int, int>;
const int INF = 0x7fffffff;
const ll divisor = 1000000007;
const int MAX_V = 150000 * 2;
int V;
vi G[MAX_V]; // グラフの隣接リスト表現
vi match(MAX_V); // マッチングのペア
vector<bool> used(MAX_V); // DFSですでに調べたかのグラフ
void add_edge(int u, int v){
G[u].PB(v);
G[v].PB(u);
}
// 増加パスをDFSで探す
bool dfs(int v){
used[v] = true;
for(int u : G[v]){
int w = match[u];
if(w < 0 || !used[w] && dfs(w)){
match[v] = u;
match[u] = v;
return true;
}
}
return false;
}
// 二部グラフの最大マッチングを求める
int bipartite_matching(){
int res = 0;
fill(all(match), -1);
rep(v, V){
if(match[v] < 0){
fill(all(used), false);
if(dfs(v)) res++;
}
}
return res;
}
int main(){
int N, M;
cin >> N >> M;
V = N + M;
vi A(N);
vi B(N);
vi C(M);
vi D(M);
rep(i, N) cin >> A[i] >> B[i];
rep(i, M) cin >> C[i] >> D[i];
rep(i, N) rep(j, M){
if(B[i] <= C[j] && D[j] <= A[i]){
add_edge(i, N + j);
}
}
cout << bipartite_matching() << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - 合コン大作戦 |
| ユーザ | pione30 |
| 言語 | C++11 (GCC 4.9.2) |
| 得点 | 0 |
| コード長 | 1802 Byte |
| 結果 | TLE |
| 実行時間 | 3100 ms |
| メモリ | 454944 KiB |
ジャッジ結果
| セット名 | Sample | Subtask1 | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 30 | 0 / 70 | ||||||||||
| 結果 |
|
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt |
| Subtask1 | 00_example_02.txt, 00_exmple_03, 00_example_04, 10_part_small_01.txt, 10_part_small_02.txt, 10_part_small_03.txt, 10_part_small_04.txt, 10_part_small_05.txt, 20_part_01.txt, 20_part_02.txt, 20_part_03.txt, 20_part_04.txt, 20_part_05.txt, 30_part_max_01.txt, 30_part_max_02.txt, 40_part_hand_01.txt, 40_part_hand_02.txt, 40_part_hand_03.txt, 40_part_hand_04.txt, 40_part_hand_05.txt, 40_part_hand_06.txt, 40_part_hand_07.txt, 40_part_hand_08.txt, 40_part_hand_09.txt, 40_part_hand_10.txt, 40_part_hand_11.txt |
| All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_part_small_01.txt, 10_part_small_02.txt, 10_part_small_03.txt, 10_part_small_04.txt, 10_part_small_05.txt, 20_part_01.txt, 20_part_02.txt, 20_part_03.txt, 20_part_04.txt, 20_part_05.txt, 30_part_max_01.txt, 30_part_max_02.txt, 40_part_hand_01.txt, 40_part_hand_02.txt, 40_part_hand_03.txt, 40_part_hand_04.txt, 40_part_hand_05.txt, 40_part_hand_06.txt, 40_part_hand_07.txt, 40_part_hand_08.txt, 40_part_hand_09.txt, 40_part_hand_10.txt, 40_part_hand_11.txt, 50_full_small_01.txt, 50_full_small_02.txt, 50_full_small_03.txt, 50_full_small_04.txt, 50_full_small_05.txt, 60_full_01.txt, 60_full_02.txt, 60_full_03.txt, 60_full_04.txt, 60_full_05.txt, 70_full_max_01.txt, 70_full_max_02.txt, 80_full_hand_01.txt, 80_full_hand_02.txt, 80_full_hand_03.txt, 80_full_hand_04.txt, 80_full_hand_05.txt, 80_full_hand_06.txt, 80_full_hand_07.txt, 80_full_hand_08.txt, 80_full_hand_09.txt, 80_full_hand_10.txt, 80_full_hand_11.txt, 80_full_hand_12.txt, 80_full_hand_13.txt, 80_full_hand_14.txt, 80_full_hand_15.txt, 80_full_hand_16.txt, 80_full_hand_17.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_example_01.txt | AC | 48 ms | 9028 KiB |
| 00_example_02.txt | AC | 43 ms | 8996 KiB |
| 00_example_03.txt | AC | 45 ms | 8988 KiB |
| 00_example_04.txt | AC | 42 ms | 8992 KiB |
| 10_part_small_01.txt | AC | 46 ms | 9128 KiB |
| 10_part_small_02.txt | AC | 45 ms | 9120 KiB |
| 10_part_small_03.txt | AC | 44 ms | 9132 KiB |
| 10_part_small_04.txt | AC | 42 ms | 8988 KiB |
| 10_part_small_05.txt | AC | 42 ms | 8996 KiB |
| 20_part_01.txt | TLE | 3068 ms | 234368 KiB |
| 20_part_02.txt | TLE | 3064 ms | 241060 KiB |
| 20_part_03.txt | TLE | 3100 ms | 454944 KiB |
| 20_part_04.txt | TLE | 3065 ms | 246580 KiB |
| 20_part_05.txt | TLE | 3077 ms | 408688 KiB |
| 30_part_max_01.txt | TLE | 3061 ms | 260212 KiB |
| 30_part_max_02.txt | TLE | 3059 ms | 222576 KiB |
| 40_part_hand_01.txt | AC | 42 ms | 8984 KiB |
| 40_part_hand_02.txt | AC | 721 ms | 9764 KiB |
| 40_part_hand_03.txt | AC | 1067 ms | 10212 KiB |
| 40_part_hand_04.txt | TLE | 3035 ms | 11432 KiB |
| 40_part_hand_05.txt | AC | 42 ms | 8996 KiB |
| 40_part_hand_06.txt | AC | 1076 ms | 15376 KiB |
| 40_part_hand_07.txt | AC | 991 ms | 15388 KiB |
| 40_part_hand_08.txt | TLE | 3060 ms | 256040 KiB |
| 40_part_hand_09.txt | TLE | 3052 ms | 160976 KiB |
| 40_part_hand_10.txt | TLE | 3057 ms | 207564 KiB |
| 40_part_hand_11.txt | TLE | 3064 ms | 261328 KiB |
| 50_full_small_01.txt | AC | 44 ms | 9008 KiB |
| 50_full_small_02.txt | AC | 42 ms | 8992 KiB |
| 50_full_small_03.txt | AC | 42 ms | 8996 KiB |
| 50_full_small_04.txt | AC | 42 ms | 8996 KiB |
| 50_full_small_05.txt | AC | 39 ms | 9044 KiB |
| 60_full_01.txt | TLE | 3048 ms | 101496 KiB |
| 60_full_02.txt | TLE | 3047 ms | 104348 KiB |
| 60_full_03.txt | TLE | 3048 ms | 109916 KiB |
| 60_full_04.txt | TLE | 3049 ms | 103716 KiB |
| 60_full_05.txt | TLE | 3047 ms | 113628 KiB |
| 70_full_max_01.txt | TLE | 3047 ms | 96424 KiB |
| 70_full_max_02.txt | TLE | 3045 ms | 100128 KiB |
| 80_full_hand_01.txt | AC | 40 ms | 8996 KiB |
| 80_full_hand_02.txt | AC | 1026 ms | 10216 KiB |
| 80_full_hand_03.txt | AC | 1019 ms | 10140 KiB |
| 80_full_hand_04.txt | TLE | 3036 ms | 11428 KiB |
| 80_full_hand_05.txt | AC | 44 ms | 8992 KiB |
| 80_full_hand_06.txt | AC | 892 ms | 12832 KiB |
| 80_full_hand_07.txt | AC | 877 ms | 12828 KiB |
| 80_full_hand_08.txt | TLE | 3052 ms | 164924 KiB |
| 80_full_hand_09.txt | TLE | 3036 ms | 11804 KiB |
| 80_full_hand_10.txt | TLE | 3067 ms | 285336 KiB |
| 80_full_hand_11.txt | TLE | 3065 ms | 288696 KiB |
| 80_full_hand_12.txt | TLE | 3036 ms | 11848 KiB |
| 80_full_hand_13.txt | TLE | 3037 ms | 11804 KiB |
| 80_full_hand_14.txt | TLE | 3055 ms | 165320 KiB |
| 80_full_hand_15.txt | TLE | 3062 ms | 256680 KiB |
| 80_full_hand_16.txt | TLE | 3052 ms | 160844 KiB |
| 80_full_hand_17.txt | TLE | 3064 ms | 244444 KiB |