답안 #1023461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023461 2024-07-14T19:07:05 Z mindiyak 곤돌라 (IOI14_gondola) C++17
25 / 100
24 ms 5080 KB
#include "gondola.h"
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000009;

int valid(int n, int arr[])
{
    int mini = arr[0],min_pos = 0;
    FOR(i,1,n){
        if(arr[i] < mini){
            mini = arr[i];
            min_pos = i;
        }
    }

    set<int> counter;
    FOR(i,min_pos,min_pos+n){
        if(counter.count(arr[i%n]))return 0;
        counter.insert(arr[i%n]);
        if(arr[i%n] > n)continue;
        if(arr[i%n] != mini+i-min_pos)return 0;
    }
    return 1;
}

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

int replacement(int n, int arr[], int replacementSeq[])
{ 
    int mini = arr[0],min_pos = 0;
    FOR(i,1,n){
        if(arr[i] < mini){
            mini = arr[i];
            min_pos = i;
        }
    }

    set<int> counter;
    priority_queue<int> removed,added;

    FOR(i,min_pos,min_pos+n){
        if(counter.count(arr[i%n]))return 0;
        counter.insert(arr[i%n]);
        if(arr[i%n] > n){
            added.push(-arr[i%n]);
            continue;
        }
        if(arr[i%n] != mini+i-min_pos)return 0;
    }

    FOR(i,1,n+1){
        if(counter.count(i))continue;
        removed.push(-i);
    }

    // cout << " arr good " << endl;

    int cnt = 0;

    while(!removed.empty()){
        replacementSeq[cnt] = -removed.top();removed.pop();
        // cout << "removed " << replacementSeq[cnt] << endl;
        cnt ++;
    }

    int last = n+1;
    while(!added.empty()){
        int to = -added.top();added.pop();
        // cout << last << " " << to << endl;
        FOR(i,last,to){
            // cout << "added " << i << endl;
            replacementSeq[cnt] = i;
            cnt ++;
        }
        last = to+1;
    }

    return cnt;
}

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

int countReplacement(int n, int inputSeq[])
{


  
}

Compilation message

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:124:1: warning: no return statement in function returning non-void [-Wreturn-type]
  124 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 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 448 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 1 ms 444 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 2352 KB Output is correct
7 Correct 6 ms 1116 KB Output is correct
8 Correct 20 ms 4400 KB Output is correct
9 Correct 5 ms 1592 KB Output is correct
10 Correct 23 ms 5080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 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 2380 KB Output is correct
7 Correct 6 ms 1116 KB Output is correct
8 Correct 20 ms 4240 KB Output is correct
9 Correct 6 ms 1624 KB Output is correct
10 Correct 24 ms 4948 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 6 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 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 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 440 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 440 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 440 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -