답안 #73621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73621 2018-08-28T15:40:21 Z MKopchev 고대 책들 (IOI17_books) C++14
0 / 100
3 ms 560 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e6+42;
int where[nmax];
bool been[nmax];
long long minimum_walk(vector<int> p, int s)
{
    int n=p.size();
    for(int i=0;i<n;i++)
        where[i]=p[i];
    long long ans=0;
    int last=0;
    for(int i=0;i<n;i++)
        if(been[i]==0)
        {
            ans=ans+i-last;
            last=i;
            int now=i;
            while(been[now]==0)
            {
                ans=ans+abs(now-where[now]);
                been[now]=1;
                now=where[now];
            }
        }
    return ans+last;
}
/*
int main()
{
cout<<minimum_walk({0, 2, 3, 1}, 0)<<endl;
return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 560 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -