Submission #39744

# Submission time Handle Problem Language Result Execution time Memory
39744 2018-01-18T04:00:01 Z deletend Gondola (IOI14_gondola) C++14
25 / 100
53 ms 7412 KB
#include <bits/stdc++.h>
#include <gondola.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int valid(int n, int inputSeq[]) {
  int d = 0, z = -1;
  map<int, int> mp;
  rep(i, 0, n) {
    if(mp[inputSeq[i]]) return 0;
    mp[inputSeq[i]] = 1;
    if(inputSeq[i] <= n) {
      if(z > inputSeq[i]) {
        if(d) return 0;
        else d = 1;
      }else if(z != -1) {
        if(z != inputSeq[i]) return 0;
      }
      z = inputSeq[i];
    }
    z++;
  }
  return 1;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
  int a[100001] = {};
  int kr;
  int mx = 0, mn = INT_MAX, mni;
  rep(i, 0, n) {
    if(mn > gondolaSeq[i]) {
      mn = gondolaSeq[i];
      mni = i;
    }
  }
  if(mn <= n) {
    rep(i, 0, n) {
      a[mni + i] = mn;
      mn++;
    }
  }
  map<int, int> mp;
  rep(i, 0, n) {
    mx = max(mx, gondolaSeq[i]);
    mp[gondolaSeq[i]] = 1;
  }
  rep(i, 0, n) {
    if(gondolaSeq[i] > n) {
      replacementSeq[gondolaSeq[i] - n - 1] = a[i];
      mp[a[i]] = 1;
    }
  }
  int ri = 0;
  rep(i, 1, mx + 1) {
    if(!mp[i]) {
      while(replacementSeq[ri]) ri++;
      replacementSeq[ri] = i;
      ri++;
    }
  }
  int c = 0;
  rep(i, 0, n) {
    if(replacementSeq[i]) c++;
  }
  return c;
}

int countReplacement(int n, int inputSeq[]) {
  if(!valid(n, inputSeq)) return 0;
  int r[100001];
  if(replacement(n, inputSeq, r) <= n) return 1;

  vector<int> v;
  int no = 0;
  rep(i, 0, n) {
    if(inputSeq[i] > n) v.pb(i);
    else no++;
  }
  return 1;
}

// int main() {
//   int n;
//   cin >> n;
//   int g[10001], gg[10001];
//   rep(i, 0, n) cin >> g[i];
//   cout << replacement(n, g, gg) << endl;
//   rep(i, 0, n) cout << gg[i] << " ";
//   cout << endl;
// }

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:41:7: warning: unused variable 'kr' [-Wunused-variable]
   int kr;
       ^
gondola.cpp:42:29: warning: 'mni' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int mx = 0, mn = INT_MAX, mni;
                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3584 KB Output is correct
2 Correct 0 ms 3584 KB Output is correct
3 Correct 0 ms 3584 KB Output is correct
4 Correct 0 ms 3584 KB Output is correct
5 Correct 0 ms 3584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3584 KB Output is correct
2 Correct 0 ms 3584 KB Output is correct
3 Correct 0 ms 3584 KB Output is correct
4 Correct 0 ms 3584 KB Output is correct
5 Correct 0 ms 3584 KB Output is correct
6 Correct 18 ms 5300 KB Output is correct
7 Correct 14 ms 3584 KB Output is correct
8 Correct 31 ms 6884 KB Output is correct
9 Correct 7 ms 4640 KB Output is correct
10 Correct 45 ms 7412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3584 KB Output is correct
2 Correct 0 ms 3584 KB Output is correct
3 Correct 0 ms 3584 KB Output is correct
4 Correct 0 ms 3584 KB Output is correct
5 Correct 0 ms 3584 KB Output is correct
6 Correct 12 ms 5300 KB Output is correct
7 Correct 13 ms 3584 KB Output is correct
8 Correct 29 ms 6884 KB Output is correct
9 Correct 8 ms 4640 KB Output is correct
10 Correct 53 ms 7412 KB Output is correct
11 Correct 0 ms 3584 KB Output is correct
12 Correct 0 ms 3584 KB Output is correct
13 Correct 7 ms 3584 KB Output is correct
14 Correct 0 ms 3584 KB Output is correct
15 Correct 22 ms 3584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3848 KB Output is correct
2 Correct 1 ms 3852 KB Output is correct
3 Correct 1 ms 3852 KB Output is correct
4 Correct 1 ms 3848 KB Output is correct
5 Correct 1 ms 3848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3848 KB Output is correct
2 Correct 0 ms 3848 KB Output is correct
3 Correct 0 ms 3848 KB Output is correct
4 Correct 0 ms 3852 KB Output is correct
5 Correct 1 ms 3852 KB Output is correct
6 Incorrect 1 ms 3852 KB Integer 6 violates the range [1, 5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3856 KB Output is correct
2 Correct 1 ms 3848 KB Output is correct
3 Correct 1 ms 3852 KB Output is correct
4 Correct 1 ms 3852 KB Output is correct
5 Correct 1 ms 3852 KB Output is correct
6 Incorrect 0 ms 3852 KB Integer 6 violates the range [1, 5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4244 KB Output is correct
2 Incorrect 0 ms 3852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Incorrect 0 ms 3852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4236 KB Output is correct
2 Incorrect 0 ms 3852 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4240 KB Output is correct
2 Incorrect 0 ms 3852 KB Output isn't correct
3 Halted 0 ms 0 KB -