Submission #853035

# Submission time Handle Problem Language Result Execution time Memory
853035 2023-09-23T10:52:52 Z aykhn Gondola (IOI14_gondola) C++14
25 / 100
25 ms 5832 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));
    }
    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:72: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]
   72 |     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 0 ms 600 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 8 ms 2772 KB Output is correct
7 Correct 20 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 18 ms 5584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 KB Output is correct
6 Correct 8 ms 2772 KB Output is correct
7 Correct 19 ms 4040 KB Output is correct
8 Correct 14 ms 4912 KB Output is correct
9 Correct 6 ms 1880 KB Output is correct
10 Correct 18 ms 5576 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 9 ms 2516 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 25 ms 5832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 1 ms 440 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 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 1 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 1 ms 344 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 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 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 0 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -