Submission #128559

#TimeUsernameProblemLanguageResultExecution timeMemory
128559BTheroBitaro’s Party (JOI18_bitaro)C++17
7 / 100
2043 ms42120 KiB
// Why am I so dumb? :c // chrono::system_clock::now().time_since_epoch().count() //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MAXN = (int)1e5 + 5; vector<pair<vector<int>, int> > req[MAXN]; map<int, int> T[MAXN]; multiset<int> S[MAXN]; vector<int> par[MAXN]; bool del[MAXN]; int deg[MAXN]; int ans[MAXN]; int n, m, q; void solve() { scanf("%d %d %d", &n, &m, &q); for (int i = 1; i <= m; ++i) { int u, v; scanf("%d %d", &u, &v); par[v].pb(u); ++deg[u]; } for (int i = 1; i <= q; ++i) { int v, sz; scanf("%d %d", &v, &sz); vector<int> tmp(sz); for (int j = 0; j < sz; ++j) { scanf("%d", &tmp[j]); } req[v].pb(mp(tmp, i)); } for (int i = 1; i <= n; ++i) { int mx = -1; for (int p : par[i]) { if (mx == -1 || T[p].size() > T[mx].size()) { mx = p; } } if (mx != -1) { for (auto it : T[mx]) { T[i][it.fi] = it.se + 1; S[i].insert(it.se + 1); } if (--deg[mx] == 0) { T[mx].clear(); S[mx].clear(); } } for (int p : par[i]) { if (p == mx) { continue; } for (auto it : T[p]) { int cur = T[i][it.fi]; if (it.se + 1 > cur) { if (cur != 0) { S[i].erase(S[i].find(cur)); } S[i].insert(it.se + 1); T[i][it.fi] = it.se + 1; } } if (--deg[p] == 0) { T[p].clear(); S[p].clear(); } } T[i][i] = 0; S[i].insert(0); for (auto it : req[i]) { vector<int> V = it.fi; int id = it.se; for (int x : V) { auto it = T[i].find(x); if (it != T[i].end()) { S[i].erase(S[i].find(it -> se)); } } if (S[i].empty()) { ans[id] = -1; } else { ans[id] = *S[i].rbegin(); } for (int x : V) { auto it = T[i].find(x); if (it != T[i].end()) { S[i].insert(it -> se); } } } } for (int i = 1; i <= q; ++i) { printf("%d\n", ans[i]); } } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void solve()':
bitaro.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &v, &sz);
         ~~~~~^~~~~~~~~~~~~~~~~~
bitaro.cpp:59:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &tmp[j]);
             ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...