Submission #430814

# Submission time Handle Problem Language Result Execution time Memory
430814 2021-06-17T06:29:46 Z Rouge_Hugo Gondola (IOI14_gondola) C++14
25 / 100
12 ms 2376 KB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#include "gondola.h"
using namespace std;
const int N=100090;
int vis[250090],r[N],yes[N],a[N],don[N];int mn=1e9,mx=0;
int valid(int n, int A[])
{
    int w=0;
    for(int i=0;i<n;i++)a[i]=A[i];
    for(int i=0;i<n;i++)yes[a[i]]=i;
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]])return 0;
        vis[a[i]]=1;
        mn=min(mn,a[i]);mx=max(mx,a[i]);
        if(mn==a[i])
            w=i;
    }
    if(mn>=n)return 1;int x=mn;
    for(int i=w+1;i<n;i++)
    {x++;
        if(a[i]>n)
        {
            a[i]=x;continue;
        }
        if(a[i]!=x)return 0;
    }
    x=a[n-1];
    for(int i=0;i<w;i++)
    {x++;
        if(a[i]>n)
        {
            a[i]=x;continue;
        }
        if(a[i]!=x)return 0;
    }
    return 1;
}
int replacement(int n, int a[], int r[])
{int w=0;
    for(int i=0;i<n;i++)yes[a[i]]=i;
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]])return 0;
        vis[a[i]]=1;
        mn=min(mn,a[i]);mx=max(mx,a[i]);
        if(mn==a[i])
            w=i;
    }
    int x=mn;
    for(int i=w+1;i<n;i++)
    {x++;
    x%=n;
    if(x==0)x=1;
        if(a[i]>n)
        {
            a[i]=x;continue;
        }
    }
    for(int i=0;i<w;i++)
    {x++;x%=n;
    if(x==0)x=1;
        if(a[i]>n)
        {
            a[i]=x;continue;
        }
    }
    int u=0;
    if(mn>n)
        for(int i=0;i<n;i++)a[i]=i+1;
    int last=0;
    for(int i=n+1;i<=mx;i++)
    {
        if(yes[i]==-1)
        {
            while(don[last])last++;
            r[u]=a[last];
            u++;
            a[last]=i;continue;
        }
        r[u]=a[yes[i]];
        don[yes[i]]=1;
        u++;
    }
    return u;
}

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:23:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   23 |     if(mn>=n)return 1;int x=mn;
      |     ^~
gondola.cpp:23:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   23 |     if(mn>=n)return 1;int x=mn;
      |                       ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 12 ms 2124 KB Output is correct
8 Correct 10 ms 1848 KB Output is correct
9 Correct 3 ms 716 KB Output is correct
10 Correct 11 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 5 ms 1084 KB Output is correct
7 Correct 11 ms 2124 KB Output is correct
8 Correct 10 ms 1740 KB Output is correct
9 Correct 5 ms 788 KB Output is correct
10 Correct 11 ms 2104 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 6 ms 1756 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 12 ms 2376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -