Submission #345053

#TimeUsernameProblemLanguageResultExecution timeMemory
345053casperwangTropical Garden (IOI11_garden)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <garden.h>
#include <gardenlib.h>
#define All(x) x.begin(), x.end()
#define pb emplace_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define ff first
#define ss second
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

const int MAXN = 150000;
const int MAXQ = 2000;

void count_routes(int N, int M, int P, int R[MAXN][2], int Q, int G[MAXQ]) {
  vector<set<ppi>> path(N);
  for (int i = 0; i < M; i++) {
    path[R[i][0]].insert(ppi(pii(0, i), R[i][1]));
    path[R[i][1]].insert(ppi(pii(0, i), R[i][0]));
  }
  vector <pii> K(Q);
  for (int i = 0; i < Q; i++) {
    K[i].ff = G[i];
    K[i].ss = i;
  }
  sort(All(K));
  int now = 0;
  vector <int> ans(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (auto &it : path[j]) it.ff.ff = 0;
    }
    for (int q = 0; q < Q; q++) {
      while (now < K[q].ff) {
        auto it = *path[cur].begin();
        path[i][cur].erase(it);
        cur = it.ss;
        it.ff.ff++;
        path[cur].insert(it);
      }
      now++;
    }
    if (cur[i] == P) ans[K[q].ss]++;
  }
  for (int q = 0; q < Q; q++) {
    answer(ans[q]);
  }
}

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:35:41: error: assignment of member 'std::pair<int, int>::first' in read-only object
   35 |       for (auto &it : path[j]) it.ff.ff = 0;
      |                                ~~~~~~~~~^~~
garden.cpp:39:25: error: 'cur' was not declared in this scope
   39 |         auto it = *path[cur].begin();
      |                         ^~~
garden.cpp:47:9: error: 'cur' was not declared in this scope
   47 |     if (cur[i] == P) ans[K[q].ss]++;
      |         ^~~
garden.cpp:47:28: error: 'q' was not declared in this scope
   47 |     if (cur[i] == P) ans[K[q].ss]++;
      |                            ^