Submission #584838

# Submission time Handle Problem Language Result Execution time Memory
584838 2022-06-28T04:44:31 Z Belgutei Gondola (IOI14_gondola) C++17
55 / 100
31 ms 5180 KB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define MOD1 1000000009
const int N = 100005;

map<int,int> mp;
map<int,int> :: iterator it;

int valid(int n, int inputSeq[]) {
  mp.clear();
  int pos = -1;
  for(int i = 0; i < n; i ++) {
    if(inputSeq[i] <= n) {
      pos = i;
    }
    mp[inputSeq[i]] ++;
  }
  for(it = mp.begin(); it != mp.end(); it ++) {
    if(it -> ss > 1) {
      return 0;
    }
  }
  if(pos == -1) return 1;
  int val = inputSeq[pos];
  for(int i = pos + 1; i < n; i ++) {
    val ++;
    if(val == n + 1) val = 1;
    if(inputSeq[i] <= n && inputSeq[i] != val) return 0;
  }
  for(int i = 0; i < pos; i ++) {
    val ++;
    if(val == n + 1) val = 1;
    if(inputSeq[i] <= n && inputSeq[i] != val) return 0;
  }
  //
  return 1;
}

//----------------------
vector<pair<int,int> > v;
int a[N], ans;

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
  int pos = -1;
  for(int i = 0; i < n; i ++) {
    if(gondolaSeq[i] > n) {
      v.pb({gondolaSeq[i], i});
    }
    else {
      pos = i;
    }
  }

  if(pos != -1) {
    int cur_pos = pos + 1;
    int cur_val = gondolaSeq[pos];
    if(cur_pos == n) cur_pos = 0; 
    while(cur_pos != pos) {
      cur_val ++;
      if(cur_val == n + 1) cur_val = 1;
      a[cur_pos] = cur_val;
      cur_pos ++;
      if(cur_pos == n) cur_pos = 0;
    }
    //
  }
  else {
    for(int i = 0; i < n; i ++) {
      a[i] = i + 1;
    }
  }
  sort(v.begin(), v.end());
  for(int i = v.size() - 1; i >= 0; i --) {
    if(i == 0) {
      for(int j = v[i].ff - 1; j > n; j --) {
        replacementSeq[ans] = j;
        ans ++;
      }
    }
    else {
      for(int j = v[i].ff - 1; j > v[i - 1].ff ; j --) {
        replacementSeq[ans] = j;
        ans ++;
      }
    }
    replacementSeq[ans] = a[v[i].ss];
    ans ++;
  }
  ans --;
  for(int i = 0; i <= ans / 2; i ++) {
    swap(replacementSeq[i], replacementSeq[ans - i]);
  }
  ans ++;
  return ans;
}

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

int countReplacement(int n, int inputSeq[]) {
  return -3;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 10 ms 2392 KB Output is correct
7 Correct 25 ms 4088 KB Output is correct
8 Correct 17 ms 4300 KB Output is correct
9 Correct 5 ms 1592 KB Output is correct
10 Correct 22 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 15 ms 2436 KB Output is correct
7 Correct 31 ms 4072 KB Output is correct
8 Correct 21 ms 4320 KB Output is correct
9 Correct 7 ms 1492 KB Output is correct
10 Correct 20 ms 5008 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 13 ms 2260 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 31 ms 5180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 9 ms 852 KB Output is correct
12 Correct 8 ms 980 KB Output is correct
13 Correct 14 ms 1652 KB Output is correct
14 Correct 6 ms 852 KB Output is correct
15 Correct 19 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -