Submission #1124418

#TimeUsernameProblemLanguageResultExecution timeMemory
1124418Yang8onBitaro’s Party (JOI18_bitaro)C++20
14 / 100
2095 ms6472 KiB
#include <bits/stdc++.h> #define Y8o "bitaro" #define maxn (int) 1e5 + 5 #define ll long long #define pii pair<int, int> #define gb(i, j) ((i >> j) & 1) #define all(x) x.begin(), x.end() #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define fi(i, a, b) for(int i = a; i <= b; i ++) #define fid(i, a, b) for(int i = a; i >= b; i --) //#define f first //#define s second using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } const int inf = 1e9; const int can = 100; int n, m, Q; vector<int> o[maxn]; int a[maxn], dp[maxn]; bool dd[maxn]; void solve() { cin >> n >> m >> Q; fi(i, 1, m) { int u, v; cin >> u >> v; o[v].push_back(u); } fi(_, 1, Q) { int root, k; cin >> root >> k ; fi(i, 1, k) cin >> a[i], dd[ a[i] ] = 1; fi(i, 1, n) { dp[i] = 0; if(dd[i]) dp[i] = -inf; } fi(u, 1, n) { for(int v : o[u]) { dp[u] = max(dp[u], dp[v] + 1); } } cout << (dp[root] < 0 ? -1 : dp[root]) << '\n'; fi(i, 1, n) dd[i] = 0; } } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void iof()':
bitaro.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...