Submission #964295

# Submission time Handle Problem Language Result Execution time Memory
964295 2024-04-16T15:13:26 Z maxFedorchuk Gondola (IOI14_gondola) C++17
55 / 100
23 ms 5332 KB
#include <bits/stdc++.h>
using namespace std;
#include "gondola.h"

int valid(int n, int inputSeq[])
{
    set < int > st;

    int p=0;
    for(int i=0;i<n;i++)
    {
        if(inputSeq[i]<=n)
        {
            p=(n+i-inputSeq[i])%n;
        }

        st.insert(inputSeq[i]);
    }

    if(st.size()!=n)
    {
        return 0;
    }

    for(int i=0;i<n;i++)
    {
        if(inputSeq[i]<=n)
        {
            if((n+i-inputSeq[i])%n!=p)
            {
                return 0;
            }
        }
    }

    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int ned_to_be[n],in=-1;
    for(int i=0;i<n;i++)
    {
        if(gondolaSeq[i]<=n)
        {
            ned_to_be[i]=gondolaSeq[i];
            in=i;
            break;
        }
    }

    if(in!=-1)
    {
        int nd=ned_to_be[in];
        for(int i=(in+1)%n;i!=in;i=(i+1)%n)
        {
            nd%=n;
            nd++;

            ned_to_be[i]=nd;
        }
    }
    else
    {
        for(int i=0;i<n;i++)
        {
            ned_to_be[i]=i+1;
        }
    }

    map < int , int > mp;

    int mx=0;
    for(int i=0;i<n;i++)
    {
        if(gondolaSeq[i]>mx)
        {
            mx=gondolaSeq[i];
            in=i;
        }

        if(gondolaSeq[i]>n)
        {
            mp[gondolaSeq[i]]=ned_to_be[i];
        }
    }

    int uk=0;
    for(int i=n+1;i<=mx;i++,uk++)
    {
        if(mp.find(i)==mp.end() || i==mx)
        {
            replacementSeq[uk]=ned_to_be[in];
            ned_to_be[in]=i;
        }
        else
        {
            replacementSeq[uk]=mp[i];
        }
    }

    return uk;
}

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

int countReplacement(int n, int inputSeq[])
{

}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(st.size()!=n)
      |        ~~~~~~~~~^~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:112:1: warning: no return statement in function returning non-void [-Wreturn-type]
  112 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 8 ms 2392 KB Output is correct
7 Correct 20 ms 4252 KB Output is correct
8 Correct 15 ms 4444 KB Output is correct
9 Correct 5 ms 1704 KB Output is correct
10 Correct 20 ms 5008 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 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 10 ms 2392 KB Output is correct
7 Correct 20 ms 4156 KB Output is correct
8 Correct 15 ms 4400 KB Output is correct
9 Correct 5 ms 1624 KB Output is correct
10 Correct 18 ms 4956 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 9 ms 2396 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 23 ms 5332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 7 ms 1456 KB Output is correct
12 Correct 7 ms 1628 KB Output is correct
13 Correct 20 ms 2792 KB Output is correct
14 Correct 6 ms 1368 KB Output is correct
15 Correct 22 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 352 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -