Submission #345052

#TimeUsernameProblemLanguageResultExecution timeMemory
345052casperwangTropical Garden (IOI11_garden)C++14
0 / 100
264 ms212844 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 <vector<set<ppi>>> path;
  vector <int> cur;
  path.resize(N);
  cur.resize(N);
  for (int i = 0; i < N; i++) path[i].resize(N), cur[i] = i;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      path[j][R[i][0]].insert(ppi(pii(0, i), R[i][1]));
      path[j][R[i][1]].insert(ppi(pii(0, i), R[i][0]));
    }
  }
  vector <pii> K;
  for (int i = 0; i < Q; i++) {
    K[i].ff = G[i];
    K[i].ss = i;
  }
  sort(All(K));
  int now = 0;
  for (int q = 0; q < Q; q++) {
    while (now < K[q].ff) {
      for (int i = 0; i < N; i++) {
        auto it = *path[i][cur[i]].begin();
        path[i][cur[i]].erase(it);
        cur[i] = it.ss;
        it.ff.ff++;
        path[i][cur[i]].insert(it);
      }
      now++;
    }
    K[q].ff = 0;
    for (int i = 0; i < N; i++) {
      if (cur[i] == P) K[q].ff++;
    }
  }
  sort(All(K), [](const pii a, const pii b) {
    return a.ss < b.ss;
  });
  for (int q = 0; q < Q; q++) {
    answer(K[q].ff);
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...