답안 #1064379

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064379 2024-08-18T12:00:47 Z anango 곤돌라 (IOI14_gondola) C++17
55 / 100
37 ms 6472 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;

int valid(int n, int inputSeq[]) {
    vector<int> pos(n,-1);
    set<int> seen;
    for (int i=0; i<n; i++) {
        if (inputSeq[i]<=n) {
            pos[inputSeq[i]-1] = i;
        }
        if (seen.count(inputSeq[i]-1)) {
            return 0;   
        }
        seen.insert(inputSeq[i]-1);
    }
    set<int> S;
    for (int i=0; i<n; i++) {
        if (pos[i]!=-1) {
            S.insert((pos[i]-i+n)%n);
        }
    }
    return S.size()<=1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
    vector<pair<int,int>> posindex;
    vector<int> actual(n,-1);
    for (int i=0; i<n; i++) {
        if (gondolaSeq[i]<=n) {
            for (int j=0; j<n; j++) {
                actual[j] = (gondolaSeq[i]-1+j-i+3*n)%n;
            }
            break;
        }
    }
    if (actual[0]==-1) {
        for (int i=0; i<n; i++) actual[i] = i;
    }
    for (int i=0; i<n; i++) {
        //cout << actual[i] <<" ";
    }
    //cout << endl;
    for (int i=0; i<n; i++) {
        posindex.push_back({gondolaSeq[i]-1,i});
    }
    sort(posindex.begin(), posindex.end());
    vector<int> repl;
    int cur = n;
    for (int i=0; i<posindex.size(); i++) {
        while (posindex[i].first>=cur) {
            repl.push_back(actual[posindex[i].second]);
            actual[posindex[i].second] = cur;
            cur++;
        }
    }
    for (int i=0; i<repl.size(); i++) {
        replacementSeq[i] = repl[i]+1;
    }
    //cout << "done " << repl.size() << endl;
    return repl.size();
}

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

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

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:52: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]
   52 |     for (int i=0; i<posindex.size(); i++) {
      |                   ~^~~~~~~~~~~~~~~~
gondola.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i=0; i<repl.size(); i++) {
      |                   ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 6 ms 1116 KB Output is correct
8 Correct 19 ms 4188 KB Output is correct
9 Correct 6 ms 1628 KB Output is correct
10 Correct 24 ms 4956 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 10 ms 2396 KB Output is correct
7 Correct 7 ms 1116 KB Output is correct
8 Correct 17 ms 4188 KB Output is correct
9 Correct 8 ms 1496 KB Output is correct
10 Correct 25 ms 4956 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 11 ms 2356 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 37 ms 6472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 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 1 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 1 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 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 9 ms 2508 KB Output is correct
12 Correct 10 ms 2768 KB Output is correct
13 Correct 10 ms 1880 KB Output is correct
14 Correct 8 ms 2516 KB Output is correct
15 Correct 13 ms 2360 KB Output is correct
# 결과 실행 시간 메모리 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 344 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 -