Submission #853036

# Submission time Handle Problem Language Result Execution time Memory
853036 2023-09-23T10:53:58 Z aykhn Gondola (IOI14_gondola) C++14
55 / 100
24 ms 6344 KB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define pb push_back
#define ins insert
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define fi first
#define se second

vector<int> ASDASD;

int ok(vector<int> &v)
{
    int n = v.size();
    set<int> s;
    for (int x : v) s.ins(x);
    if (s.size() != v.size()) return 0;
    vector<int> a(n, 0);
    int anc = -1;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] <= n) 
        {
            anc = i;
            break;
        }
    }
    if (anc == -1) 
    {
        ASDASD = v;
        return 1;
    }
    int shift = n + v[anc] - anc - 1;
    for (int i = 0; i < n; i++) a[(i + shift + 10*n) % n] = v[i];
    ASDASD = a;
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= n && a[i] != i + 1) return 0;
    }
    return 1;
}

int valid(int n, int in[])
{
    vector<int> v;
    for (int i = 0; i < n; i++) v.pb(in[i]);
    return ok(v);
}

int replacement(int n, int in[], int ret[])
{
    vector<int> v;
    for (int i = 0; i < n; i++) v.pb(in[i]);
    ok(v);
    v = ASDASD;
    vector<pii> a;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == i + 1) continue;
        a.pb(mpr(v[i], i + 1));
    }
    sort(all(a));
    int j = 0;
    int rn = n + 1;
    for (int i = 0; i < a.size(); i++)
    {
        ret[j++] = a[i].se;
        while (a[i].fi > rn) ret[j++] = rn++;
        rn++;
    }
    return j;
}

int countReplacement(int n, int in[])
{
    return -1;
}

Compilation message

gondola.cpp: In function 'int ok(std::vector<int>&)':
gondola.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
gondola.cpp:73:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 8 ms 2776 KB Output is correct
7 Correct 19 ms 4048 KB Output is correct
8 Correct 15 ms 4820 KB Output is correct
9 Correct 5 ms 1880 KB Output is correct
10 Correct 19 ms 5584 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 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 8 ms 2772 KB Output is correct
7 Correct 20 ms 4124 KB Output is correct
8 Correct 15 ms 4816 KB Output is correct
9 Correct 5 ms 2136 KB Output is correct
10 Correct 21 ms 5584 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 10 ms 2520 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 24 ms 5844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 496 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 18 ms 5840 KB Output is correct
12 Correct 21 ms 6344 KB Output is correct
13 Correct 19 ms 3012 KB Output is correct
14 Correct 18 ms 5584 KB Output is correct
15 Correct 19 ms 3208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -