Submission #706150

# Submission time Handle Problem Language Result Execution time Memory
706150 2023-03-06T01:50:08 Z LLLLLLLLLLLLLLLLLLLLLLL Gondola (IOI14_gondola) C++14
60 / 100
28 ms 5080 KB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

const int MOD = 1e9 + 9;
const int INF = 0x3f3f3f3f;

int valid(int n, int v[]){
    set<int> s(v, v + n);
    if((int) s.size() != n) return 0;

    for(int i = 0; i < n; i++){
        if(v[i] > n) continue;

        int left = (v[i] == 1 ? n : v[i] - 1), right = (v[i] == n ? 1 : v[i] + 1);

        int lefViz = (i == 0 ? v[n - 1] : v[i - 1]);
        int rigViz = (i == n - 1 ? v[0] : v[i + 1]);

        if((lefViz != left && lefViz <= n) || (rigViz != right && rigViz <= n)) return 0;
    }

    return 1;
}

int countReplacement(int n, int v[]){
    if(!valid(n, v)) return 0;
    return 1;
}

int replacement(int n, int v[], int answer[]){
    vector<int> order(n);
    vector<pair<int, int>> aux;

    int mn = INF, mnidx = 0;

    for(int i = 0; i < n; i++)
        if(v[i] < mn){ mn = v[i]; mnidx = i; }

    if(mn > n) mnidx = 0, mn = 1;

    for(int i = 0; i < n; i++){
        order[(i + mnidx) % n] = mn;
        mn = (mn == n ? 1 : mn + 1);
    }

    for(int i = 0; i < n; i++)
        if(v[i] > n) aux.push_back({v[i], order[i]});

    sort(aux.begin(), aux.end());

    int numOp = 0;

    for(int i = 0, val = n; i < aux.size(); i++){
        answer[numOp++] = aux[i].second; val++;

        while(val < aux[i].first)
            answer[numOp++] = val++;
    }
    
    return numOp;
}

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:54:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i = 0, val = n; i < aux.size(); i++){
      |                             ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 2376 KB Output is correct
7 Correct 24 ms 4172 KB Output is correct
8 Correct 18 ms 4308 KB Output is correct
9 Correct 4 ms 1492 KB Output is correct
10 Correct 15 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 2364 KB Output is correct
7 Correct 23 ms 4040 KB Output is correct
8 Correct 17 ms 4308 KB Output is correct
9 Correct 4 ms 1580 KB Output is correct
10 Correct 14 ms 4920 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 12 ms 2216 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 28 ms 5080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 1264 KB Output is correct
12 Correct 9 ms 1492 KB Output is correct
13 Correct 13 ms 1372 KB Output is correct
14 Correct 7 ms 1364 KB Output is correct
15 Correct 18 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 216 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 308 KB Output isn't correct
6 Halted 0 ms 0 KB -