Submission #796721

# Submission time Handle Problem Language Result Execution time Memory
796721 2023-07-28T16:09:47 Z vjudge1 Bitaro's travel (JOI23_travel) C++17
Compilation error
0 ms 0 KB
        for(; cr_l != -1 && cr_r != n;) {
            if(s - a[cr_l] > a[cr_r] - s) {
                l = cr_r, r = n;
                for(; l + 1 < r;) {
                    m = (l + r) / 2;
                    (a[m] - s < s - a[cr_l] ? l : r) = m;
                }
                ans += a[l] - s;
                s = a[l];
                cr_r = r;
            } else {
                l = -1, r = cr_l;
                for(; l + 1 < r;) {
                    m = (l + r) / 2;
                    (a[cr_r] - s < s - a[l] ? l : r) = m;
                }
                ans += s - a[r];
                s = a[r];
                cr_l = l;
            }
        }
        if(cr_r < n) {
            ans += a[n - 1] - s;
        } else if(cr_l > -1) {
            ans += s - a[0];
        }
        cout << ans << '\n';
    }
}

Compilation message

travel.cpp:1:9: error: expected unqualified-id before 'for'
    1 |         for(; cr_l != -1 && cr_r != n;) {
      |         ^~~
travel.cpp:1:15: error: 'cr_l' does not name a type
    1 |         for(; cr_l != -1 && cr_r != n;) {
      |               ^~~~
travel.cpp:1:39: error: expected unqualified-id before ')' token
    1 |         for(; cr_l != -1 && cr_r != n;) {
      |                                       ^
travel.cpp:22:9: error: expected unqualified-id before 'if'
   22 |         if(cr_r < n) {
      |         ^~
travel.cpp:24:11: error: expected unqualified-id before 'else'
   24 |         } else if(cr_l > -1) {
      |           ^~~~
travel.cpp:27:9: error: 'cout' does not name a type
   27 |         cout << ans << '\n';
      |         ^~~~
travel.cpp:28:5: error: expected declaration before '}' token
   28 |     }
      |     ^
travel.cpp:29:1: error: expected declaration before '}' token
   29 | }
      | ^