Submission #1005808

# Submission time Handle Problem Language Result Execution time Memory
1005808 2024-06-23T05:36:09 Z Gray Gondola (IOI14_gondola) C++17
55 / 100
33 ms 6616 KB
#include<bits/stdc++.h>
#include "gondola.h"
#define ll long long
#define ff first
#define ss second
#define ln "\n"

using namespace std;


int valid(int n, int inputSeq[])
{
  vector<ll> sn(n);
  ll trunk=-1;
  map<ll, ll> usd;
  for (ll i=0; i<n; i++){
    if (usd[inputSeq[i]]) return 0;
    usd[inputSeq[i]]=1;
    if (inputSeq[i]<=n) {
      sn[i]=inputSeq[i];
      trunk=i;
    }
  }
  if (trunk==-1) return 1;
  ll init = inputSeq[trunk]-1;
  for (ll i=trunk-1; i>=0; i--){
    sn[i]=(--init+n)%n+1;
  }
  init=inputSeq[trunk]-1;
  for (ll i=trunk+1; i<n; i++){
    sn[i]=(++init)%n+1;
  }
  for (ll i=0; i<n; i++){
    if (inputSeq[i]<=n and inputSeq[i]!=sn[i]) return 0;
  }
  return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  vector<ll> sn(n);
  ll trunk=-1;
  for (ll i=0; i<n; i++){
    if (gondolaSeq[i]<=n) {
      sn[i]=gondolaSeq[i];
      trunk=i;
    }
  }
  ll init = gondolaSeq[trunk]-1;
  for (ll i=trunk-1; i>=0; i--){
    sn[i]=(--init+n)%n+1;
  }
  init=gondolaSeq[trunk]-1;
  for (ll i=trunk+1; i<n; i++){
    sn[i]=(++init)%n+1;
  }
  vector<pair<ll, ll>> rep;
  for (ll i=0; i<n; i++){
    if (gondolaSeq[i]>n){
      rep.push_back({gondolaSeq[i], sn[i]});
    }
  }
  sort(rep.begin(), rep.end());
  ll len=0, prev=n, last;
  for (ll i=0; i<(ll)rep.size(); i++){
    // cout << rep[i].ff << " " << rep[i].ss << ln;
    last=rep[i].ss;
    while (prev<rep[i].ff){
      replacementSeq[len]=last;
      len++;
      last=++prev;
    } 
  }
  return len;
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 11 ms 3128 KB Output is correct
7 Correct 6 ms 1372 KB Output is correct
8 Correct 29 ms 5724 KB Output is correct
9 Correct 6 ms 2140 KB Output is correct
10 Correct 25 ms 6568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 11 ms 3160 KB Output is correct
7 Correct 6 ms 1372 KB Output is correct
8 Correct 23 ms 5616 KB Output is correct
9 Correct 6 ms 2140 KB Output is correct
10 Correct 26 ms 6484 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 14 ms 2908 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 33 ms 6616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 376 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 5 ms 1712 KB Output is correct
12 Correct 6 ms 1880 KB Output is correct
13 Correct 10 ms 1752 KB Output is correct
14 Correct 6 ms 1628 KB Output is correct
15 Correct 12 ms 2376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -