답안 #55214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55214 2018-07-06T11:45:42 Z dfistric Sailing Race (CEOI12_race) C++14
0 / 100
366 ms 7164 KB
#include <bits/stdc++.h>

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

using namespace std;

const int MAXN = 510;
vector <int> ve[MAXN];
int num_ways[MAXN][MAXN][2];

bool inside(int x, int y, int z, int t) {
  if (t == 0) swap(x, y);
  if (x < y) {
    return ((z >= x) && (z <= y));
  }
  return ((z >= x) || (z <= y));
}

int rek(int x, int y, int t) {
  int& out = num_ways[x][y][t];
  if (out != -1) return out;

  out = 0;
  for (int z : ve[y]) {
    if (!inside(x, y, z, t)) continue;
  //  cout << x + 1 << " " << y + 1 << " " << t << " -> " << z + 1 << endl;
    out = max(out, 1 + max(rek(y, z, 1 - t), rek(x, z, t)));
  }
  //cout << x + 1 << " " << y + 1 << " " << t << " --- " << out << endl;
  return out;
}

int main() {
  ios_base::sync_with_stdio(false);
  memset(num_ways, -1, sizeof num_ways);

  int n, k;
  cin >> n >> k;
  REP(i, n) {
    int x;
    cin >> x;
    while (x) {
      ve[i].push_back(x - 1);
      //cout << i << " " << x - 1 << endl;
      cin >> x;
    }
  }

  int out = 0, st = 0;
  REP(i, n) {
    for (int j : ve[i]) {
      int tr = 1 + max(rek(i, j, 1), rek(i, j, 0));
      if (tr > out) {
        out = tr;
        st = i + 1;
      }
      //cout << i << " " << j << ": " << tr << endl;
    }
  }
cout << out << "\n" << st << "\n";

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2424 KB Output isn't correct
2 Incorrect 3 ms 2424 KB Output isn't correct
3 Incorrect 3 ms 2476 KB Output isn't correct
4 Incorrect 5 ms 2524 KB Output isn't correct
5 Incorrect 6 ms 2556 KB Output isn't correct
6 Incorrect 4 ms 2556 KB Output isn't correct
7 Incorrect 7 ms 2820 KB Output isn't correct
8 Incorrect 6 ms 2820 KB Output isn't correct
9 Incorrect 9 ms 2820 KB Output isn't correct
10 Incorrect 22 ms 3028 KB Output isn't correct
11 Incorrect 13 ms 3028 KB Output isn't correct
12 Incorrect 27 ms 3248 KB Output isn't correct
13 Incorrect 51 ms 3552 KB Output isn't correct
14 Incorrect 78 ms 3948 KB Output isn't correct
15 Incorrect 250 ms 5396 KB Output isn't correct
16 Incorrect 288 ms 5736 KB Output isn't correct
17 Incorrect 231 ms 5736 KB Output isn't correct
18 Incorrect 88 ms 5736 KB Output isn't correct
19 Incorrect 357 ms 6376 KB Output isn't correct
20 Incorrect 366 ms 7164 KB Output isn't correct