답안 #72838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72838 2018-08-27T04:20:59 Z funcsr 고대 책들 (IOI17_books) C++17
50 / 100
441 ms 36972 KB
#include "books.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i,n)for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
typedef pair<int, int> P;

int N;
bool used[1000000];
int T[1000000];
vector<int> G[1000000];

long long minimum_walk(vector<int> A, int S) {
  N = A.size();
  vector<P> ps;
  int m = INF;
  rep(i, N) if (!used[i]) {
    if (i == A[i]) continue;
    int x = i;
    int left = x, right = x;
    int lmin = INF, rmin = INF;
    int w = INF;
    while (!used[x]) {
      left = min(left, x);
      right = max(x, right);
      w = min(w, abs(S-x));

      if (x <= S) lmin = min(lmin, S-x);
      else rmin = min(rmin, x-S);

      if (x < A[x]) {
        T[x]++;
        T[A[x]]--;
      }
      used[x] = true;
      x = A[x];
    }
    //if (left < S && S < right) G[lmin].pb(rmin);
    if (left < S && S < right) m = min(m, w);
  }

  rep(i,N-1) T[i+1] += T[i];
  long long cost = 0;
  bool yes = false;
  for (int i=N-1; i>=S; i--) {
    if (T[i])yes=true;
    cost += max(T[i], (int)yes);
  }
  yes = false;
  for (int i=0; i<S; i++) {
    if (T[i])yes=true;
    cost += max(T[i], (int)yes);
  }

  /*
  int m = INF;
  int rm = 0;
  for (int left=N-1; left>=0; left--) {
    m = min(m, left+rm);
    for (int r : G[left]) rm = max(rm, r);
  }
  */
  if (m != INF) cost += m;
  return 2LL*cost;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 28 ms 23908 KB Output is correct
3 Correct 27 ms 23908 KB Output is correct
4 Correct 29 ms 24020 KB Output is correct
5 Correct 31 ms 24020 KB Output is correct
6 Correct 31 ms 24020 KB Output is correct
7 Correct 32 ms 24020 KB Output is correct
8 Correct 30 ms 24020 KB Output is correct
9 Correct 26 ms 24020 KB Output is correct
10 Correct 27 ms 24020 KB Output is correct
11 Correct 28 ms 24020 KB Output is correct
12 Correct 29 ms 24020 KB Output is correct
13 Correct 30 ms 24124 KB Output is correct
14 Correct 28 ms 24124 KB Output is correct
15 Correct 35 ms 24124 KB Output is correct
16 Correct 26 ms 24124 KB Output is correct
17 Correct 27 ms 24124 KB Output is correct
18 Correct 27 ms 24124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 28 ms 23908 KB Output is correct
3 Correct 27 ms 23908 KB Output is correct
4 Correct 29 ms 24020 KB Output is correct
5 Correct 31 ms 24020 KB Output is correct
6 Correct 31 ms 24020 KB Output is correct
7 Correct 32 ms 24020 KB Output is correct
8 Correct 30 ms 24020 KB Output is correct
9 Correct 26 ms 24020 KB Output is correct
10 Correct 27 ms 24020 KB Output is correct
11 Correct 28 ms 24020 KB Output is correct
12 Correct 29 ms 24020 KB Output is correct
13 Correct 30 ms 24124 KB Output is correct
14 Correct 28 ms 24124 KB Output is correct
15 Correct 35 ms 24124 KB Output is correct
16 Correct 26 ms 24124 KB Output is correct
17 Correct 27 ms 24124 KB Output is correct
18 Correct 27 ms 24124 KB Output is correct
19 Correct 28 ms 24124 KB Output is correct
20 Correct 27 ms 24124 KB Output is correct
21 Correct 28 ms 24176 KB Output is correct
22 Correct 27 ms 24176 KB Output is correct
23 Correct 27 ms 24176 KB Output is correct
24 Correct 30 ms 24176 KB Output is correct
25 Correct 26 ms 24176 KB Output is correct
26 Correct 27 ms 24176 KB Output is correct
27 Correct 29 ms 24176 KB Output is correct
28 Correct 27 ms 24176 KB Output is correct
29 Correct 32 ms 24176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 28 ms 23908 KB Output is correct
3 Correct 27 ms 23908 KB Output is correct
4 Correct 29 ms 24020 KB Output is correct
5 Correct 31 ms 24020 KB Output is correct
6 Correct 31 ms 24020 KB Output is correct
7 Correct 32 ms 24020 KB Output is correct
8 Correct 30 ms 24020 KB Output is correct
9 Correct 26 ms 24020 KB Output is correct
10 Correct 27 ms 24020 KB Output is correct
11 Correct 28 ms 24020 KB Output is correct
12 Correct 29 ms 24020 KB Output is correct
13 Correct 30 ms 24124 KB Output is correct
14 Correct 28 ms 24124 KB Output is correct
15 Correct 35 ms 24124 KB Output is correct
16 Correct 26 ms 24124 KB Output is correct
17 Correct 27 ms 24124 KB Output is correct
18 Correct 27 ms 24124 KB Output is correct
19 Correct 28 ms 24124 KB Output is correct
20 Correct 27 ms 24124 KB Output is correct
21 Correct 28 ms 24176 KB Output is correct
22 Correct 27 ms 24176 KB Output is correct
23 Correct 27 ms 24176 KB Output is correct
24 Correct 30 ms 24176 KB Output is correct
25 Correct 26 ms 24176 KB Output is correct
26 Correct 27 ms 24176 KB Output is correct
27 Correct 29 ms 24176 KB Output is correct
28 Correct 27 ms 24176 KB Output is correct
29 Correct 32 ms 24176 KB Output is correct
30 Correct 441 ms 36732 KB Output is correct
31 Correct 376 ms 36844 KB Output is correct
32 Correct 204 ms 36844 KB Output is correct
33 Correct 237 ms 36844 KB Output is correct
34 Correct 216 ms 36844 KB Output is correct
35 Correct 239 ms 36844 KB Output is correct
36 Correct 241 ms 36844 KB Output is correct
37 Correct 219 ms 36844 KB Output is correct
38 Correct 220 ms 36844 KB Output is correct
39 Correct 298 ms 36844 KB Output is correct
40 Correct 274 ms 36844 KB Output is correct
41 Correct 338 ms 36844 KB Output is correct
42 Correct 295 ms 36972 KB Output is correct
43 Correct 265 ms 36972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 36972 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2746'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 23800 KB Output is correct
2 Correct 28 ms 23908 KB Output is correct
3 Correct 27 ms 23908 KB Output is correct
4 Correct 29 ms 24020 KB Output is correct
5 Correct 31 ms 24020 KB Output is correct
6 Correct 31 ms 24020 KB Output is correct
7 Correct 32 ms 24020 KB Output is correct
8 Correct 30 ms 24020 KB Output is correct
9 Correct 26 ms 24020 KB Output is correct
10 Correct 27 ms 24020 KB Output is correct
11 Correct 28 ms 24020 KB Output is correct
12 Correct 29 ms 24020 KB Output is correct
13 Correct 30 ms 24124 KB Output is correct
14 Correct 28 ms 24124 KB Output is correct
15 Correct 35 ms 24124 KB Output is correct
16 Correct 26 ms 24124 KB Output is correct
17 Correct 27 ms 24124 KB Output is correct
18 Correct 27 ms 24124 KB Output is correct
19 Correct 28 ms 24124 KB Output is correct
20 Correct 27 ms 24124 KB Output is correct
21 Correct 28 ms 24176 KB Output is correct
22 Correct 27 ms 24176 KB Output is correct
23 Correct 27 ms 24176 KB Output is correct
24 Correct 30 ms 24176 KB Output is correct
25 Correct 26 ms 24176 KB Output is correct
26 Correct 27 ms 24176 KB Output is correct
27 Correct 29 ms 24176 KB Output is correct
28 Correct 27 ms 24176 KB Output is correct
29 Correct 32 ms 24176 KB Output is correct
30 Correct 441 ms 36732 KB Output is correct
31 Correct 376 ms 36844 KB Output is correct
32 Correct 204 ms 36844 KB Output is correct
33 Correct 237 ms 36844 KB Output is correct
34 Correct 216 ms 36844 KB Output is correct
35 Correct 239 ms 36844 KB Output is correct
36 Correct 241 ms 36844 KB Output is correct
37 Correct 219 ms 36844 KB Output is correct
38 Correct 220 ms 36844 KB Output is correct
39 Correct 298 ms 36844 KB Output is correct
40 Correct 274 ms 36844 KB Output is correct
41 Correct 338 ms 36844 KB Output is correct
42 Correct 295 ms 36972 KB Output is correct
43 Correct 265 ms 36972 KB Output is correct
44 Incorrect 31 ms 36972 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2746'
45 Halted 0 ms 0 KB -