Submission #1017523

# Submission time Handle Problem Language Result Execution time Memory
1017523 2024-07-09T08:39:18 Z Ice_man Gondola (IOI14_gondola) C++14
55 / 100
48 ms 5124 KB
/**
 ____    ____    ____    __________________    ____    ____    ____
||I ||  ||c ||  ||e ||  ||                ||  ||M ||  ||a ||  ||n ||
||__||  ||__||  ||__||  ||________________||  ||__||  ||__||  ||__||
|/__\|  |/__\|  |/__\|  |/________________\|  |/__\|  |/__\|  |/__\|

*/

#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <map>

#include "gondola.h"

#define maxn 1005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;

using namespace std;


typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double ld;


std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;

double timePassed()
{
    using namespace std::chrono;
    currT = high_resolution_clock::now();
    double time = duration_cast<duration<double>>(currT - startT).count();
    return time * TIME_MULT;
}




int valid(int n, int a[])
{
    map <int , int> br;
    int minn = INF , idx;

    for(int i = 0; i < n; i++)
    {
        if(minn > a[i])
        {
            minn = a[i];
            idx = i;
        }

        br[a[i]]++;
        if(br[a[i]] > 1)
            return false;
    }

    if(minn > n)
        return true;

    int curr = minn + 1;

    for(int i = idx + 1; i % n != idx; i++)
    {
        if(a[i % n] <= n && a[i % n] != curr)
            return false;
        curr++;
    }

    return true;
}




int replacement(int n, int a[], int r[])
{

    int idx = 0;
    int delta = INF;

    vector <pii> v;
    for(int i = 0; i < n; i++)
    {
        if(a[i] <= n && a[i] < delta)
        {
            delta = a[i];
            idx = i;
        }

        if(a[i] > n)
            v.push_back({a[i] , i});
    }

    if(delta == INF)
        delta = 1;
    sort(v.begin() , v.end());

    int next = n + 1 , curr = 0;
    int old;
    for(auto& e : v)
    {
        if(e.Y < idx)
            old = n - idx + e.Y + delta;
        else
            old = e.Y - idx + delta;
        old %= n;
        if(old == 0)
            old = n;

        r[curr] = old;
        curr++;

        while(next != e.X)
        {
            r[curr] = next;
            next++;
            curr++;
        }

        next = e.X + 1;
    }

    return curr;
}



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

















/**int main()
{

#ifdef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ///startT = std::chrono::high_resolution_clock::now();





    return 0;
}
*/

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:57:22: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |     int minn = INF , idx;
      |                      ^~~
# 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 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 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 444 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 12 ms 2360 KB Output is correct
7 Correct 6 ms 1112 KB Output is correct
8 Correct 17 ms 4444 KB Output is correct
9 Correct 8 ms 1480 KB Output is correct
10 Correct 32 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 15 ms 2572 KB Output is correct
7 Correct 11 ms 1080 KB Output is correct
8 Correct 25 ms 4432 KB Output is correct
9 Correct 9 ms 1624 KB Output is correct
10 Correct 23 ms 5084 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 14 ms 2396 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 48 ms 5124 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 344 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 1 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 444 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 436 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 440 KB Output is correct
6 Correct 0 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 5 ms 1116 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 9 ms 1516 KB Output is correct
14 Correct 9 ms 1056 KB Output is correct
15 Correct 17 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -