Submission #763631

# Submission time Handle Problem Language Result Execution time Memory
763631 2023-06-22T14:27:37 Z Ahmed57 Gondola (IOI14_gondola) C++17
45 / 100
18 ms 2324 KB
#include "gondola.h"

#include <bits/stdc++.h>

using namespace std;

int valid(int n, int inputSeq[]){
    bool ss = 0;
    int ind = 0 , val = 0;
    for(int i = 0;i<n;i++){
        if(inputSeq[i]<=n){
            ss = 1;
            val = inputSeq[i]-1;
            ind = i;
        }
    }
    if(!ss)return 1;
    for(int i = ind+1;i<n;i++){
        val++;
        val%=n;
        if(inputSeq[i]<=n){
            if((inputSeq[i]-1)!=val)return 0;
        }
    }
    for(int i = 0;i<ind;i++){
        val++;val%=n;
        if(inputSeq[i]<=n){
            if((inputSeq[i]-1)!=val)return 0;
        }
    }
    return 1;
}int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    vector<pair<int,int>> v;
    int ind = 0, val = 0;bool ss = 0;
    for(int i = 0;i<n;i++){
        if(gondolaSeq[i]<=n){
            ind = i;val = gondolaSeq[i]-1;
            ss = 1;
        }
    }
    int lol[n];
    if(ss){
        lol[ind] = val;
        for(int i = ind+1;i<n;i++){
            val++;
            val%=n;
            lol[i] = val;
        }
        for(int i = 0;i<ind;i++){
            val++;val%=n;
            lol[i] = val;
        }
    }
    for(int i = 0;i<n;i++){
        if(gondolaSeq[i]>n){
            v.push_back({gondolaSeq[i],(ss==0?i+1:lol[i]+1)});
        }
    }
    sort(v.begin(),v.end());
    int l = n+1;
    int st =0;
    for(int i = 0;i<v.size();i++){
        replacementSeq[st++] = v[i].second;
        ++l;
        while(l<=v[i].first){
            replacementSeq[st++] = l-1;
            l++;
        }
    }
    return st;
}
int countReplacement(int n, int inputSeq[]){
    return 0;
}
/*
int main(){
    int S[] = {10, 4, 3, 11, 12};
    cout<<valid(6,S);
}*/

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:62:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i = 0;i<v.size();i++){
      |                   ~^~~~~~~~~
# 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 1 ms 288 KB Output is correct
5 Correct 1 ms 212 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 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 7 ms 1108 KB Output is correct
8 Correct 6 ms 1008 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 7 ms 1088 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 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 596 KB Output is correct
7 Correct 7 ms 1144 KB Output is correct
8 Correct 6 ms 980 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 7 ms 1104 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 1 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 340 KB Output is correct
11 Correct 7 ms 1364 KB Output is correct
12 Correct 8 ms 1472 KB Output is correct
13 Correct 11 ms 1532 KB Output is correct
14 Correct 6 ms 1340 KB Output is correct
15 Correct 18 ms 2324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -