답안 #763635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763635 2023-06-22T14:30:26 Z Ahmed57 곤돌라 (IOI14_gondola) C++17
55 / 100
15 ms 2312 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;
    map<int,int> mp;
    for(int i = 0;i<n;i++){
        if(inputSeq[i]<=n){
            ss = 1;
            val = inputSeq[i]-1;
            ind = i;
        }else{
            if(mp[inputSeq[i]]==1){
                return 0;
            }mp[inputSeq[i]] = 1;
        }
    }
    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:67: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]
   67 |     for(int i = 0;i<v.size();i++){
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 5 ms 468 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 Correct 0 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 6 ms 596 KB Output is correct
8 Correct 6 ms 468 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 596 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 13 ms 2260 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 13 ms 2088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 6 ms 852 KB Output is correct
12 Correct 8 ms 980 KB Output is correct
13 Correct 12 ms 1340 KB Output is correct
14 Correct 6 ms 852 KB Output is correct
15 Correct 15 ms 2312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -