#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#define m_p make_pair
#define fi first
#define se second
typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;
int x[MAXN*2], a[MAXN*2];
int main()
{
int n, i, j;
scanf("%d\n", &n);
for (i=1; i<=n; i++) x[i]=i-1;
for (i=1; i<=n; i++) scanf("%d", &a[i]);
for (j=1; j<=50000000/n; j++){
for (i=1; i<=n; i++){
x[i+1]=min(x[i+1], x[i]+1);
x[a[i]]=min(x[a[i]], x[i]+1);
}
for (i=n; i>1; i--){
x[i-1]=min(x[i-1], x[i]+1);
x[a[i]]=min(x[a[i]], x[i]+1);
}
}
for (i=1; i<=n; i++){
cout << x[i];
if (i != n) cout << " "; else cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8aW9tYW5pcD4KCiNkZWZpbmUgbV9wIG1ha2VfcGFpcgojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKY29uc3QgaW50IE1BWElOVD0yMTQ3NDgzNjQwOwpjb25zdCBsbCBNQVhMTD05MjIzMzcyMDM2ODU0Nzc1ODAwOwpjb25zdCBsbCBNQVhOPTEwMDAwMDA7CmNvbnN0IGRvdWJsZSBwaT0zLjE0MTU5MjY1MzU4OTc5MzIzODQ2MjY0MzM4MzI3OTU7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgeFtNQVhOKjJdLCBhW01BWE4qMl07CmludCBtYWluKCkKewogICAgaW50IG4sIGksIGo7CiAgICBzY2FuZigiJWRcbiIsICZuKTsKICAgIGZvciAoaT0xOyBpPD1uOyBpKyspIHhbaV09aS0xOwogICAgZm9yIChpPTE7IGk8PW47IGkrKykgc2NhbmYoIiVkIiwgJmFbaV0pOwoKICAgIGZvciAoaj0xOyBqPD01MDAwMDAwMC9uOyBqKyspewogICAgICAgIGZvciAoaT0xOyBpPD1uOyBpKyspewogICAgICAgICAgICB4W2krMV09bWluKHhbaSsxXSwgeFtpXSsxKTsKICAgICAgICAgICAgeFthW2ldXT1taW4oeFthW2ldXSwgeFtpXSsxKTsKICAgICAgICB9CiAgICAgICAgZm9yIChpPW47IGk+MTsgaS0tKXsKICAgICAgICAgICAgeFtpLTFdPW1pbih4W2ktMV0sIHhbaV0rMSk7CiAgICAgICAgICAgIHhbYVtpXV09bWluKHhbYVtpXV0sIHhbaV0rMSk7CiAgICAgICAgfQogICAgfQogICAgZm9yIChpPTE7IGk8PW47IGkrKyl7CiAgICAgICAgY291dCA8PCB4W2ldOwogICAgICAgIGlmIChpICE9IG4pIGNvdXQgPDwgIiAiOyBlbHNlIGNvdXQgPDwgZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:1: error: class, interface, or enum expected
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <cstdio>
^
Main.java:3: error: illegal character: '#'
#include <algorithm>
^
Main.java:4: error: illegal character: '#'
#include <cmath>
^
Main.java:5: error: illegal character: '#'
#include <map>
^
Main.java:6: error: illegal character: '#'
#include <vector>
^
Main.java:7: error: illegal character: '#'
#include <cstring>
^
Main.java:8: error: illegal character: '#'
#include <iomanip>
^
Main.java:10: error: illegal character: '#'
#define m_p make_pair
^
Main.java:11: error: illegal character: '#'
#define fi first
^
Main.java:12: error: illegal character: '#'
#define se second
^
Main.java:15: error: class, interface, or enum expected
const int MAXINT=2147483640;
^
Main.java:16: error: class, interface, or enum expected
const ll MAXLL=9223372036854775800;
^
Main.java:17: error: class, interface, or enum expected
const ll MAXN=1000000;
^
Main.java:18: error: class, interface, or enum expected
const double pi=3.1415926535897932384626433832795;
^
Main.java:19: error: class, interface, or enum expected
using namespace std;
^
Main.java:21: error: class, interface, or enum expected
int x[MAXN*2], a[MAXN*2];
^
Main.java:22: error: class, interface, or enum expected
int main()
^
Main.java:25: error: class, interface, or enum expected
scanf("%d\n", &n);
^
Main.java:26: error: class, interface, or enum expected
for (i=1; i<=n; i++) x[i]=i-1;
^
Main.java:26: error: class, interface, or enum expected
for (i=1; i<=n; i++) x[i]=i-1;
^
Main.java:26: error: class, interface, or enum expected
for (i=1; i<=n; i++) x[i]=i-1;
^
Main.java:27: error: class, interface, or enum expected
for (i=1; i<=n; i++) scanf("%d", &a[i]);
^
Main.java:27: error: class, interface, or enum expected
for (i=1; i<=n; i++) scanf("%d", &a[i]);
^
Main.java:27: error: class, interface, or enum expected
for (i=1; i<=n; i++) scanf("%d", &a[i]);
^
Main.java:29: error: class, interface, or enum expected
for (j=1; j<=50000000/n; j++){
^
Main.java:29: error: class, interface, or enum expected
for (j=1; j<=50000000/n; j++){
^
Main.java:29: error: class, interface, or enum expected
for (j=1; j<=50000000/n; j++){
^
Main.java:30: error: class, interface, or enum expected
for (i=1; i<=n; i++){
^
Main.java:30: error: class, interface, or enum expected
for (i=1; i<=n; i++){
^
Main.java:32: error: class, interface, or enum expected
x[a[i]]=min(x[a[i]], x[i]+1);
^
Main.java:33: error: class, interface, or enum expected
}
^
Main.java:34: error: class, interface, or enum expected
for (i=n; i>1; i--){
^
Main.java:34: error: class, interface, or enum expected
for (i=n; i>1; i--){
^
Main.java:36: error: class, interface, or enum expected
x[a[i]]=min(x[a[i]], x[i]+1);
^
Main.java:37: error: class, interface, or enum expected
}
^
Main.java:39: error: class, interface, or enum expected
for (i=1; i<=n; i++){
^
Main.java:39: error: class, interface, or enum expected
for (i=1; i<=n; i++){
^
Main.java:41: error: class, interface, or enum expected
if (i != n) cout << " "; else cout << endl;
^
Main.java:41: error: class, interface, or enum expected
if (i != n) cout << " "; else cout << endl;
^
Main.java:42: error: class, interface, or enum expected
}
^
Main.java:44: error: class, interface, or enum expected
}
^
43 errors