Submission #1020328

# Submission time Handle Problem Language Result Execution time Memory
1020328 2024-07-11T23:47:06 Z aaaaaarroz Islands (IOI08_islands) C++17
Compilation error
0 ms 0 KB
    #include <bits/stdc++.h>
     
    using namespace std;
    using ll = long long;
     
    const int MxN = 1000010;
     
    pair<int, ll> nxt[MxN];
    bitset<MxN> cycle;
    int in[MxN];
    queue<int> q;
    ll dist[MxN], dp[MxN];
     
    signed main(int argc, char *argv[]) {
      cin.tie(nullptr)->ios::sync_with_stdio(false);
      int n;
      cin >> n;
      for(int i=1; i<=n; ++i) {
        cin >> nxt[i].first >> nxt[i].second;
        in[nxt[i].first]++;
      }
      for(int i=1; i<=n; ++i) {
        if(in[i] != 0) {
          continue;
        }
        q.emplace(i);
      }
      while(!q.empty()) {
        int u = q.front(); q.pop();
        int v = nxt[u].first;
        ll w = nxt[u].second;
        dp[v] = max({dp[u], dp[v], dist[v] + dist[u] + w});
        dist[v] = max(dist[v], dist[u] + w);
        if (--in[v] == 0) {
            q.emplace(v);
        }
      }
      auto calc = [&](int pos) {
        int cur_pos = pos;
        cur_pos = nxt[pos].first;
        ll cur_dist = nxt[pos].second;
        ll with = dist[pos];
        ll without = dist[pos];
        ll max_dp_with = dp[pos];
        ll max_dp_without = -1e18 - 100ll;
        while(cur_pos != pos) {
          in[cur_pos] = 0;
          max_dp_with = max({max_dp_with, dp[cur_pos], dist[cur_pos] + cur_dist + with});
          max_dp_without = max(max_dp_without, dist[cur_pos] - cur_dist + without);
          with = max(with, dist[cur_pos] - cur_dist);
          without = max(without, dist[cur_pos] + cur_dist);
          cur_dist += nxt[cur_pos].second;
          cur_pos = nxt[cur_pos].first;< max_dp_with << " " << max_dp_without << "\n";
       }
        return max(max_dp_without + cur_dist, max_dp_with);
      };
      ll answer = 0ll;
      for(int i=1; i<=n; ++i) {
        if(in[i] == 0) {
          continue;
        }
        answer += calc(i);
      }
      cout << answer << "\n";
      return 0;
    }

Compilation message

islands.cpp: In lambda function:
islands.cpp:53:40: error: expected primary-expression before '<' token
   53 |           cur_pos = nxt[cur_pos].first;< max_dp_with << " " << max_dp_without << "\n";
      |                                        ^
islands.cpp:53:54: error: invalid operands of types 'll' {aka 'long long int'} and 'const char [2]' to binary 'operator<<'
   53 |           cur_pos = nxt[cur_pos].first;< max_dp_with << " " << max_dp_without << "\n";
      |                                          ~~~~~~~~~~~ ^~ ~~~
      |                                          |              |
      |                                          |              const char [2]
      |                                          ll {aka long long int}