답안 #920941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920941 2024-02-03T08:13:25 Z salmon 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 1372 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;



long long minimum_walk(vector<int> p, int s) {
    bool done[1100100];
    int N = p.size();

    int un = N;
    int soom = 0;

    /*while(un != 0){
        if(start )
    }*/


    int big = 0;
    for(int i = 0; i < N; i++){
        if(done[i]) continue;
        done[i] = true;

        big = i;

        int j = p[i];
        soom += abs(j - i);
        while(j != i){
            int temp = j;
            done[j] = true;
            j = p[j];
            soom += abs(temp - j);
        }
    }


    return soom + 2 * big;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:11:9: warning: unused variable 'un' [-Wunused-variable]
   11 |     int un = N;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Incorrect 1 ms 1372 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Incorrect 1 ms 1372 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Incorrect 1 ms 1372 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1368 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Incorrect 1 ms 1372 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -