fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <map>
  6. #include <vector>
  7. #include <cstring>
  8. #include <iomanip>
  9.  
  10. #define m_p make_pair
  11. #define fi first
  12. #define se second
  13.  
  14. typedef long long ll;
  15. const int MAXINT=2147483640;
  16. const ll MAXLL=9223372036854775800;
  17. const ll MAXN=1000000;
  18. const double pi=3.1415926535897932384626433832795;
  19. using namespace std;
  20.  
  21. int x[MAXN*2], a[MAXN*2];
  22. int main()
  23. {
  24. int n, i, j;
  25. scanf("%d\n", &n);
  26. for (i=1; i<=n; i++) x[i]=i-1;
  27. for (i=1; i<=n; i++) scanf("%d", &a[i]);
  28.  
  29. for (j=1; j<=50000000/n; j++){
  30. for (i=1; i<=n; i++){
  31. x[i+1]=min(x[i+1], x[i]+1);
  32. x[a[i]]=min(x[a[i]], x[i]+1);
  33. }
  34. for (i=n; i>1; i--){
  35. x[i-1]=min(x[i-1], x[i]+1);
  36. x[a[i]]=min(x[a[i]], x[i]+1);
  37. }
  38. }
  39. for (i=1; i<=n; i++){
  40. cout << x[i];
  41. if (i != n) cout << " "; else cout << endl;
  42. }
  43. return 0;
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty