Submission #39715

# Submission time Handle Problem Language Result Execution time Memory
39715 2018-01-18T01:29:48 Z funcsr Gondola (IOI14_gondola) C++14
55 / 100
33 ms 7576 KB
#include "gondola.h"
#include <iostream>
#include <vector>
#include <cassert>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()

int A[100000], cur[100000];
int cnt[250000];
bool glock;
int valid(int N, int inputSeq[]) {
  rep(i, 250000) cnt[i] = 0;
  rep(i, N) A[i] = inputSeq[i]-1;
  rep(i, N) cnt[A[i]]++;
  rep(i, 250000) if (cnt[i] > 1) return 0;
  int base = -1;
  rep(i, N) if (A[i] < N) base = (A[i]-i+N)%N;
  rep(i, N) cur[i] = (i+max(0,base))%N;
  glock = false;
  if (base == -1) return 1;
  glock = true;
  rep(i, N) if (A[i] < N && A[i] != cur[i]) return 0;
  return 1;
}

//----------------------

int rev[250000];
set<int> unused;
int replacement(int N, int gondolaSeq[], int replacementSeq[]) {
  assert(valid(N, gondolaSeq));
  rep(i, N) rev[A[i]] = i;
  rep(i, N) if (A[i] >= N) unused.insert(i);
  int m = *max_element(A, A+N);
  int c = 0;
  for (int i=N; i<=m; i++) {
    int p = -1;
    if (cnt[i]) {
      p = rev[i];
      unused.erase(rev[i]);
    }
    else p = *unused.begin();
    replacementSeq[c++] = cur[p]+1;
    cur[p] = i;
  }
  return c;
}

//----------------------

int countReplacement(int N, int inputSeq[]) {
  if (valid(N, inputSeq) == 0) return 0;
  return -3;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 0 ms 6124 KB Output is correct
5 Correct 1 ms 6124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 0 ms 6124 KB Output is correct
5 Correct 1 ms 6124 KB Output is correct
6 Correct 7 ms 6124 KB Output is correct
7 Correct 10 ms 6124 KB Output is correct
8 Correct 10 ms 6124 KB Output is correct
9 Correct 4 ms 6124 KB Output is correct
10 Correct 13 ms 6124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 0 ms 6124 KB Output is correct
5 Correct 1 ms 6124 KB Output is correct
6 Correct 4 ms 6124 KB Output is correct
7 Correct 14 ms 6124 KB Output is correct
8 Correct 9 ms 6124 KB Output is correct
9 Correct 4 ms 6124 KB Output is correct
10 Correct 13 ms 6124 KB Output is correct
11 Correct 1 ms 6124 KB Output is correct
12 Correct 1 ms 6124 KB Output is correct
13 Correct 6 ms 6124 KB Output is correct
14 Correct 1 ms 6124 KB Output is correct
15 Correct 17 ms 6124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 1 ms 6124 KB Output is correct
5 Correct 1 ms 6124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 1 ms 6124 KB Output is correct
5 Correct 1 ms 6124 KB Output is correct
6 Correct 1 ms 6124 KB Output is correct
7 Correct 1 ms 6124 KB Output is correct
8 Correct 1 ms 6124 KB Output is correct
9 Correct 1 ms 6124 KB Output is correct
10 Correct 2 ms 6124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6124 KB Output is correct
2 Correct 1 ms 6124 KB Output is correct
3 Correct 1 ms 6124 KB Output is correct
4 Correct 1 ms 6124 KB Output is correct
5 Correct 0 ms 6124 KB Output is correct
6 Correct 1 ms 6124 KB Output is correct
7 Correct 1 ms 6124 KB Output is correct
8 Correct 1 ms 6124 KB Output is correct
9 Correct 1 ms 6124 KB Output is correct
10 Correct 1 ms 6124 KB Output is correct
11 Correct 14 ms 6124 KB Output is correct
12 Correct 12 ms 6124 KB Output is correct
13 Correct 33 ms 7576 KB Output is correct
14 Correct 13 ms 6124 KB Output is correct
15 Correct 30 ms 6916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6124 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 6124 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6124 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6124 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -