답안 #55197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55197 2018-07-06T09:53:39 Z jklepec Sailing Race (CEOI12_race) C++11
0 / 100
135 ms 5376 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 505;

bool inside(int l, int r, int k, int w) {

  if(w == l || w == r || l == r) return false;

  if(l > r) {
    swap(r, l);
    k ^= 1;
  }

  if(k) {
    return (w > l && r > w);
  }
  return !(w > l && r > w);
}

vector<int> e[MAXN];
int mem[MAXN][MAXN][2];

int calc(int l, int r, int k) {

  if(mem[l][r][k] != -1) {
    return mem[l][r][k];
  }

  int ret = 0;
  for(auto w: e[l]) {
    if(inside(l, r, k, w)) {
      ret = max(ret, 1 + calc(w, r, k));
      ret = max(ret, 1 + calc(w, l, k ^ 1));
    }
  }

  return mem[l][r][k] = ret;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  memset(mem, -1, sizeof mem);

  int n, k; cin >> n >> k;
  assert(k == 0);

  REP(i, n) {
    int x; cin >> x;
    while(x) {
      e[i].push_back(x - 1);

      cin >> x;
    }
  }

  int sol = 0;
  REP(i, n) for(auto j: e[i]) {
    sol = max(sol, calc(j, i, 1));
    sol = max(sol, calc(j, i, 0));
  }

  cout << sol + 1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2296 KB Unexpected end of file - int32 expected
2 Runtime error 7 ms 4584 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 8 ms 4728 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 9 ms 4768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Incorrect 7 ms 4816 KB Unexpected end of file - int32 expected
6 Runtime error 8 ms 4816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Incorrect 10 ms 4956 KB Unexpected end of file - int32 expected
8 Runtime error 8 ms 4956 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 10 ms 4956 KB Unexpected end of file - int32 expected
10 Incorrect 23 ms 5020 KB Unexpected end of file - int32 expected
11 Incorrect 14 ms 5020 KB Unexpected end of file - int32 expected
12 Runtime error 8 ms 5096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 6 ms 5124 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 89 ms 5124 KB Unexpected end of file - int32 expected
15 Runtime error 6 ms 5180 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 8 ms 5212 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 7 ms 5232 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Incorrect 135 ms 5376 KB Unexpected end of file - int32 expected
19 Runtime error 10 ms 5376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 9 ms 5376 KB Execution killed with signal 11 (could be triggered by violating memory limits)