# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
345053 | casperwang | 열대 식물원 (Tropical Garden) (IOI11_garden) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
}