Submission #1064501

# Submission time Handle Problem Language Result Execution time Memory
1064501 2024-08-18T13:35:35 Z Charizard2021 Gondola (IOI14_gondola) C++17
25 / 100
29 ms 4956 KB
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]){
    set<int> s;
    bool works = true;
    int idx = 0;
    for(int i = 0; i < n; i++){
        s.insert(inputSeq[i]);
        if(inputSeq[i] <= n){
            idx = i;
            works = false;
        }
    }
    if((int)s.size() != n){
        return 0;
    }
    if(works){
        return 1;
    }
    int a[n];
    int val = inputSeq[idx];
    for(int i = idx; i < n; i++){
        a[i] = val++;
        val %= n;
        if(val == 0) val = n;
    }
    for(int i = 0; i < idx; i++){
        a[i] = val++;
        val %= n;
        if(val == 0) val = n;
    }
    bool works2 = true;
    for(int i = 0; i < n; i++){
        if(inputSeq[i] <= n){
            if(inputSeq[i] != a[i]){
                works2 = false;
            }
        }
    }
    if(works2){
        return 1;
    }
    return 0;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    //3, 8, 5, 6, 2
    int maxVal = 0;
    int minVal = INT_MAX;
    for(int x = 0; x < n; x++){
        maxVal = max(maxVal, gondolaSeq[x]);
        minVal = min(minVal, gondolaSeq[x]);
    }
    if(maxVal <= n){
        return 0;
    }
    if(minVal > n){
        return 0;
    }
    int x[maxVal + 1];
    for(int a = n + 1; a <= maxVal; a++){
        x[a] = 0;
    }
    int idx = 0;
    for(int i = 0; i < n; i++){
        if(gondolaSeq[i] <= n){
            idx = i;
        }
    }
    int a[n];
    int val = gondolaSeq[idx];
    for(int i = idx; i < n; i++){
        a[i] = val++;
        val %= n;
        if(val == 0) val = n;
    }
    for(int i = 0; i < idx; i++){
        a[i] = val++;
        val %= n;
        if(val == 0) val = n;
    }
    for(int i = 0; i < n; i++){
        if(gondolaSeq[i] > n){
            x[gondolaSeq[i]] = a[i];
        }
    }
    for(int i = maxVal; i >= n + 1; i--){
        if(x[i] == 0){
            x[i] = x[i + 1];
        }
    }
    map<int, vector<int> > mp;
    for(int i = n + 1; i <= maxVal; i++){
        mp[x[i]].push_back(i);
    }
    int val9 = 0;
    int idx9 = 0;
    for(auto it : mp){
        val9 += (int)it.second.size();
        replacementSeq[idx9++] = it.first;
        for(int c : it.second){
            if(c == it.second.back()){
                break;
            }
            replacementSeq[idx9++] = c;
        }
    }
    return val9;
}

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

int countReplacement(int n, int inputSeq[]){
    return -3;
}
# 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 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 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 0 ms 348 KB Output is correct
6 Correct 12 ms 2396 KB Output is correct
7 Correct 20 ms 3660 KB Output is correct
8 Correct 14 ms 4188 KB Output is correct
9 Correct 5 ms 1532 KB Output is correct
10 Correct 18 ms 4956 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 2332 KB Output is correct
7 Correct 29 ms 3676 KB Output is correct
8 Correct 23 ms 4188 KB Output is correct
9 Correct 7 ms 1540 KB Output is correct
10 Correct 28 ms 4844 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 12 ms 2140 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 26 ms 4956 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 0 ms 344 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 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Integer 1019 violates the range [1, 991]
8 Halted 0 ms 0 KB -
# 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 1 ms 444 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 Incorrect 1 ms 348 KB Integer 1019 violates the range [1, 991]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -