답안 #1043026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043026 2024-08-03T18:00:04 Z ALeonidou 곤돌라 (IOI14_gondola) C++17
25 / 100
26 ms 5848 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define  F first
#define S second
#define pb push_back
#define endl "\n"
#define sz(x) (ll)x.size()
#define ins insert

typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;

#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;

void printVct(vi &v){
	for (ll i =0; i<sz(v); i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}

//subtask 1 & 2 & 3
int valid(int n, int arr[]){
    ll p = 0;
    set <ll> st; st.ins(arr[0]);
    for (ll i=1; i<n; i++){
        if (arr[p] > arr[i]) p = i;
        if (st.find(arr[i]) == st.end()){
            st.ins(arr[i]);
        }
        else{
            return 0;
        }
    }

    if (arr[p] > n) return 1;

    vi v;
    for (ll i = p; i<n; i++){
        if (arr[i] <= n) v.pb(arr[i]);
        else v.pb(v.back()+1);
    }
    for (ll i =0; i<p; i++){
        if (arr[i] <= n) v.pb(arr[i]);
        else v.pb(v.back()+1);
    }

    for (ll i =1; i<n; i++){
        if (v[i] != v[i-1] + 1){
            return 0;
        }
    }

    return 1;
}

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

//subtask 4,5,6
inline void add_to_ans(ll x, ll &ans_size, int ans[]){
    ans[ans_size] = x;
    ans_size++;
}

int replacement(int n, int arr[], int ans[])
{
    ll ans_size = 0;
    vii misplaced_sorted;
    ll firstIdx = 0;
    for (ll i=0; i<n; i++){
        if (arr[i] <= n){
            firstIdx = ((i - (arr[i] - 1)) + n) % n;
        }
        else{
            misplaced_sorted.pb(ii(arr[i], i));
        }
    }
    sort(misplaced_sorted.begin(), misplaced_sorted.end());

    vi rel_idx(n);
    ll c = 1;
    for (ll i =firstIdx; i<n; i++){
        rel_idx[i] = c;
        c++;
    }
    for (ll i =0; i<firstIdx; i++){
        rel_idx[i] = c;
        c++;
    }

    // dbg(firstIdx);
    // printVct(rel_idx);

    ll prev = n;
    for (ll i =0; i<sz(misplaced_sorted); i++){
        // dbg3(i, misplaced_sorted[i].F, misplaced_sorted[i].S);
        add_to_ans(rel_idx[misplaced_sorted[i].S], ans_size, ans);
        for (ll j = prev+1; j<misplaced_sorted[i].F; i++){
            add_to_ans(j, ans_size, ans);
        }
        prev = misplaced_sorted[i].F;
    }

    // cout<<"ans: ";
    // for (ll i=0; i<ans_size; i++){
    //     cout<<ans[i]<<" ";
    // }
    // cout<<endl;

    return ans_size;
}

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

int countReplacement(int n, int inputSeq[])
{
    return -3;
}


/*
1
5
1 2 3 4 5

*/
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 8 ms 2776 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 15 ms 5156 KB Output is correct
9 Correct 5 ms 1884 KB Output is correct
10 Correct 21 ms 5612 KB Output is correct
# 결과 실행 시간 메모리 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 9 ms 2852 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 16 ms 5172 KB Output is correct
9 Correct 5 ms 1884 KB Output is correct
10 Correct 22 ms 5848 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 10 ms 2664 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 26 ms 5848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -