Submission #93786

# Submission time Handle Problem Language Result Execution time Memory
93786 2019-01-11T10:44:07 Z Bodo171 Gondola (IOI14_gondola) C++14
75 / 100
19 ms 5368 KB
#include "gondola.h"
#include <iostream>
using namespace std;
const int nmax=100005;
const long long mod=1000*1000*1000+9;
int ap[10*nmax];
int v[nmax];
int i,act;
void permuta(int a[],int b[],int n)
{
    int offset=0;
    for(int i=0;i<n;i++)
        if(a[i]<=n)
            offset=i+1-a[i];
    for(int i=0;i<n;i++)
        b[i]=a[(i+offset+n)%n];
}
int valid(int n, int inputSeq[])
{
  permuta(inputSeq,v,n);
  for(int i=0;i<n;i++)
    {
        if(v[i]<=n&&v[i]!=i+1)
           return 0;
        if(ap[v[i]]) return 0;
        ap[v[i]]=1;
   }

  return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  int l=0;
  permuta(gondolaSeq,v,n);
  int mx=0;
  for(i=0;i<n;i++)
  {
     ap[v[i]]=i+1;
     mx=max(mx,v[i]);
  }
  act=n;
  for(i=n+1;i<=mx;i++)
    if(ap[i])
  {
     replacementSeq[l++]=ap[i];
     act++;
     while(act<i)
     {
        replacementSeq[l++]=act;
        act++;
     }
  }
  return l;
}

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

int countReplacement(int n, int inputSeq[])
{
    long long f=0,ans=1;
  if(!valid(n,inputSeq)) return 0;
  for(int i=1000*1000;i>n;i--)
  {
      if(ap[i])  ap[i]+=ap[i+1];
      else
      {
          ap[i]=ap[i+1];
          f=ap[i];
          if(f)ans=(1LL*ans*f)%mod;
      }
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 1 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 6 ms 760 KB Output is correct
7 Correct 12 ms 1048 KB Output is correct
8 Correct 10 ms 1144 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 11 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 7 ms 760 KB Output is correct
7 Correct 11 ms 1020 KB Output is correct
8 Correct 10 ms 1144 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 11 ms 1272 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 6 ms 888 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 12 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 10 ms 1272 KB Output is correct
12 Correct 11 ms 1400 KB Output is correct
13 Correct 13 ms 1784 KB Output is correct
14 Correct 10 ms 1272 KB Output is correct
15 Correct 18 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 8 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 7 ms 4216 KB Output is correct
3 Correct 10 ms 4344 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 8 ms 4220 KB Output is correct
6 Correct 8 ms 4216 KB Output is correct
7 Correct 7 ms 4216 KB Output is correct
8 Correct 7 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4280 KB Output is correct
2 Correct 7 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 8 ms 4216 KB Output is correct
5 Correct 8 ms 4216 KB Output is correct
6 Correct 9 ms 4216 KB Output is correct
7 Correct 8 ms 4216 KB Output is correct
8 Correct 8 ms 4220 KB Output is correct
9 Correct 19 ms 5368 KB Output is correct
10 Correct 16 ms 5132 KB Output is correct
11 Correct 12 ms 4472 KB Output is correct
12 Correct 12 ms 4600 KB Output is correct
13 Incorrect 9 ms 4344 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 8 ms 4216 KB Output is correct
6 Correct 8 ms 4216 KB Output is correct
7 Correct 8 ms 4216 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 18 ms 5368 KB Output is correct
10 Correct 16 ms 5112 KB Output is correct
11 Correct 11 ms 4472 KB Output is correct
12 Correct 12 ms 4600 KB Output is correct
13 Incorrect 9 ms 4344 KB Output isn't correct
14 Halted 0 ms 0 KB -