Submission #1196349

#TimeUsernameProblemLanguageResultExecution timeMemory
1196349dostsGondola (IOI14_gondola)C++20
10 / 100
5 ms1092 KiB
#include "gondola.h"
#include <bits/stdc++.h>
#pragma GCC target("lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sp << " " << 
using namespace std;


int valid(int n, int inputSeq[])
{
  vi pos(n+1,-1);
  for (int i=0;i<n;i++) if (inputSeq[i] <= n) pos[inputSeq[i]] = i;
  int frst = -1;
  for (int j = 1;j<=n;j++) {
    if (pos[j] != -1) {
      frst = pos[j];
      break;
    }
  }
  int lst = -1;
  for (int j = 1;j<=n;j++) {
    if (pos[j] == -1) continue;
    pos[j] = (pos[j]-frst+n)%n;
    if (lst != -1 && pos[j] < lst) return 0;
    lst = pos[j];
  }
  return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...