답안 #73629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73629 2018-08-28T15:49:51 Z MKopchev 고대 책들 (IOI17_books) C++14
0 / 100
3 ms 676 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&&i!=where[i])
        {
            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;
//cout<<minimum_walk({1,0,3,2}, 0)<<endl;
return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 3 ms 584 KB Output is correct
6 Incorrect 2 ms 584 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 3 ms 584 KB Output is correct
6 Incorrect 2 ms 584 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 3 ms 584 KB Output is correct
6 Incorrect 2 ms 584 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 676 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 3 ms 584 KB Output is correct
5 Correct 3 ms 584 KB Output is correct
6 Incorrect 2 ms 584 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -