Submission #75369


Source Code Expand

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

const int MAX_LR = 30010;

int L, R;
vector<int> adj[MAX_LR];
bool vis[MAX_LR], usd[MAX_LR];
int lev[MAX_LR + 1], mat[MAX_LR];

bool augment(int l) {
  if (l == L) return true;
  if (vis[l]) return false;
  vis[l] = true;
  rep (i, adj[l].size()) {
    int r = adj[l][i], l2 = mat[r];
    if (lev[l2] > lev[l] && augment(l2)) {
      mat[r] = l;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  fill(mat, mat + R, L);
  memset(usd, 0, sizeof(bool) * L);
  bool update;
  do {
    fill(lev, lev + L + 1, -1);
    lev[L] = R;
    queue<int> que;
    rep (l, L) if (!usd[l]) {
      que.push(l);
      lev[l] = 0;
    }
    while (!que.empty()) {
      int l = que.front();
      que.pop();
      rep (i, adj[l].size()) {
        int r = adj[l][i], l2 = mat[r];
        if (lev[l2] < 0) {
          lev[l2] = lev[l] + 1;
          que.push(l2);
        }
      }
    }

    memset(vis, 0, sizeof(bool) * L);
    update = false;
    rep (l, L) if (!usd[l] && augment(l)) usd[l] = update = true;
  } while (update);

  return count(usd, usd + L, true);
}

int main() {
  int N;
  while (1 == scanf("%d", &N)) {
    int X[3000][3];
    rep (i, N) rep (j, 3) scanf("%d", &X[i][j]);

    map<int, int> id;
    vector<pair<int, int> > es;

    rep (i, N) {
      int t = X[i][0] * X[i][1] * X[i][2];
      rep (j, 3) for (int x = 1; x < X[i][j]; ++x) {
        int a = t / X[i][j] * x;
        int b = t / X[i][j] * (X[i][j] - x);
        id[a] = id[b] = 0;
        es.pb(mp(a, b));
      }
    }

    int V = 0;
    tr (id, ite) ite->second = V++;
    fprintf(stderr, "V=%d\n", V);

    L = R = V;
    rep (i, L) adj[i].clear();
    rep (i, es.size()) adj[id[es[i].first]].pb(id[es[i].second]);

    int m = bipartite_matching();
    printf("%d\n", L + R - m);
  }

  return 0;
}

Submission Info

Submission Time
Task D - 切り分けできるかな?
User iwiwi
Language C++ (G++ 4.6.4)
Score 100
Code Size 2517 Byte
Status AC
Exec Time 25 ms
Memory 1584 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:83:48: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name part1 part2
Score / Max Score 20 / 20 80 / 80
Status
AC × 33
AC × 66
Set Name Test Cases
part1 small/small_00_sample_02.txt, small/small_01_rand_00.txt, small/small_01_rand_01.txt, small/small_01_rand_02.txt, small/small_01_rand_03.txt, small/small_01_rand_04.txt, small/small_01_rand_05.txt, small/small_01_rand_06.txt, small/small_01_rand_07.txt, small/small_01_rand_08.txt, small/small_01_rand_09.txt, small/small_02_maxrand_00.txt, small/small_02_maxrand_01.txt, small/small_02_maxrand_02.txt, small/small_02_maxrand_03.txt, small/small_02_maxrand_04.txt, small/small_02_maxrand_05.txt, small/small_02_maxrand_06.txt, small/small_02_maxrand_07.txt, small/small_02_maxrand_08.txt, small/small_02_maxrand_09.txt, small/small_03_maxrandp_00.txt, small/small_03_maxrandp_01.txt, small/small_03_maxrandp_02.txt, small/small_03_maxrandp_03.txt, small/small_03_maxrandp_04.txt, small/small_03_maxrandp_05.txt, small/small_03_maxrandp_06.txt, small/small_03_maxrandp_07.txt, small/small_03_maxrandp_08.txt, small/small_03_maxrandp_09.txt, small/small_99_min2.txt, small/small_99_minmin.txt
part2 small/small_00_sample_02.txt, small/small_01_rand_00.txt, small/small_01_rand_01.txt, small/small_01_rand_02.txt, small/small_01_rand_03.txt, small/small_01_rand_04.txt, small/small_01_rand_05.txt, small/small_01_rand_06.txt, small/small_01_rand_07.txt, small/small_01_rand_08.txt, small/small_01_rand_09.txt, small/small_02_maxrand_00.txt, small/small_02_maxrand_01.txt, small/small_02_maxrand_02.txt, small/small_02_maxrand_03.txt, small/small_02_maxrand_04.txt, small/small_02_maxrand_05.txt, small/small_02_maxrand_06.txt, small/small_02_maxrand_07.txt, small/small_02_maxrand_08.txt, small/small_02_maxrand_09.txt, small/small_03_maxrandp_00.txt, small/small_03_maxrandp_01.txt, small/small_03_maxrandp_02.txt, small/small_03_maxrandp_03.txt, small/small_03_maxrandp_04.txt, small/small_03_maxrandp_05.txt, small/small_03_maxrandp_06.txt, small/small_03_maxrandp_07.txt, small/small_03_maxrandp_08.txt, small/small_03_maxrandp_09.txt, small/small_99_min2.txt, small/small_99_minmin.txt, large/large_00_sample_01.txt, large/large_00_sample_03.txt, large/large_00_sample_04.txt, large/large_01_rand_00.txt, large/large_01_rand_01.txt, large/large_01_rand_02.txt, large/large_01_rand_03.txt, large/large_01_rand_04.txt, large/large_01_rand_05.txt, large/large_01_rand_06.txt, large/large_01_rand_07.txt, large/large_01_rand_08.txt, large/large_01_rand_09.txt, large/large_02_maxrand_00.txt, large/large_02_maxrand_01.txt, large/large_02_maxrand_02.txt, large/large_02_maxrand_03.txt, large/large_02_maxrand_04.txt, large/large_02_maxrand_05.txt, large/large_02_maxrand_06.txt, large/large_02_maxrand_07.txt, large/large_02_maxrand_08.txt, large/large_02_maxrand_09.txt, large/large_03_maxrandp_00.txt, large/large_03_maxrandp_01.txt, large/large_03_maxrandp_02.txt, large/large_03_maxrandp_03.txt, large/large_03_maxrandp_04.txt, large/large_03_maxrandp_05.txt, large/large_03_maxrandp_06.txt, large/large_03_maxrandp_07.txt, large/large_03_maxrandp_08.txt, large/large_03_maxrandp_09.txt
Case Name Status Exec Time Memory
large/large_00_sample_01.txt AC 22 ms 1464 KB
large/large_00_sample_03.txt AC 22 ms 1556 KB
large/large_00_sample_04.txt AC 22 ms 1336 KB
large/large_01_rand_00.txt AC 22 ms 1532 KB
large/large_01_rand_01.txt AC 23 ms 1560 KB
large/large_01_rand_02.txt AC 22 ms 1556 KB
large/large_01_rand_03.txt AC 23 ms 1556 KB
large/large_01_rand_04.txt AC 22 ms 1552 KB
large/large_01_rand_05.txt AC 23 ms 1464 KB
large/large_01_rand_06.txt AC 23 ms 1552 KB
large/large_01_rand_07.txt AC 22 ms 1548 KB
large/large_01_rand_08.txt AC 23 ms 1560 KB
large/large_01_rand_09.txt AC 23 ms 1552 KB
large/large_02_maxrand_00.txt AC 23 ms 1548 KB
large/large_02_maxrand_01.txt AC 24 ms 1564 KB
large/large_02_maxrand_02.txt AC 23 ms 1456 KB
large/large_02_maxrand_03.txt AC 23 ms 1556 KB
large/large_02_maxrand_04.txt AC 23 ms 1460 KB
large/large_02_maxrand_05.txt AC 24 ms 1556 KB
large/large_02_maxrand_06.txt AC 24 ms 1560 KB
large/large_02_maxrand_07.txt AC 23 ms 1556 KB
large/large_02_maxrand_08.txt AC 24 ms 1560 KB
large/large_02_maxrand_09.txt AC 23 ms 1556 KB
large/large_03_maxrandp_00.txt AC 23 ms 1452 KB
large/large_03_maxrandp_01.txt AC 25 ms 1392 KB
large/large_03_maxrandp_02.txt AC 23 ms 1548 KB
large/large_03_maxrandp_03.txt AC 23 ms 1556 KB
large/large_03_maxrandp_04.txt AC 23 ms 1556 KB
large/large_03_maxrandp_05.txt AC 22 ms 1560 KB
large/large_03_maxrandp_06.txt AC 23 ms 1584 KB
large/large_03_maxrandp_07.txt AC 23 ms 1556 KB
large/large_03_maxrandp_08.txt AC 23 ms 1560 KB
large/large_03_maxrandp_09.txt AC 23 ms 1460 KB
small/small_00_sample_02.txt AC 24 ms 1412 KB
small/small_01_rand_00.txt AC 22 ms 1560 KB
small/small_01_rand_01.txt AC 22 ms 1460 KB
small/small_01_rand_02.txt AC 22 ms 1556 KB
small/small_01_rand_03.txt AC 22 ms 1548 KB
small/small_01_rand_04.txt AC 22 ms 1556 KB
small/small_01_rand_05.txt AC 21 ms 1552 KB
small/small_01_rand_06.txt AC 22 ms 1556 KB
small/small_01_rand_07.txt AC 22 ms 1552 KB
small/small_01_rand_08.txt AC 22 ms 1552 KB
small/small_01_rand_09.txt AC 22 ms 1512 KB
small/small_02_maxrand_00.txt AC 22 ms 1580 KB
small/small_02_maxrand_01.txt AC 22 ms 1536 KB
small/small_02_maxrand_02.txt AC 22 ms 1556 KB
small/small_02_maxrand_03.txt AC 22 ms 1556 KB
small/small_02_maxrand_04.txt AC 22 ms 1432 KB
small/small_02_maxrand_05.txt AC 21 ms 1556 KB
small/small_02_maxrand_06.txt AC 21 ms 1576 KB
small/small_02_maxrand_07.txt AC 23 ms 1456 KB
small/small_02_maxrand_08.txt AC 23 ms 1464 KB
small/small_02_maxrand_09.txt AC 23 ms 1456 KB
small/small_03_maxrandp_00.txt AC 22 ms 1468 KB
small/small_03_maxrandp_01.txt AC 22 ms 1432 KB
small/small_03_maxrandp_02.txt AC 22 ms 1436 KB
small/small_03_maxrandp_03.txt AC 22 ms 1560 KB
small/small_03_maxrandp_04.txt AC 21 ms 1552 KB
small/small_03_maxrandp_05.txt AC 22 ms 1556 KB
small/small_03_maxrandp_06.txt AC 22 ms 1556 KB
small/small_03_maxrandp_07.txt AC 22 ms 1556 KB
small/small_03_maxrandp_08.txt AC 21 ms 1552 KB
small/small_03_maxrandp_09.txt AC 22 ms 1460 KB
small/small_99_min2.txt AC 22 ms 1560 KB
small/small_99_minmin.txt AC 22 ms 1452 KB