Submission #761832

#TimeUsernameProblemLanguageResultExecution timeMemory
761832YassineBenYounesBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms468 KiB
#include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<pair<int, int>, null_type, less<pair<int, int>>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1}; int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ////////////////////Only Clear Code////////////////////////// void usaco_problem(){ freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout); } void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 1005; const int LOG = 25; const int inf = 1e9+5; const ll mod = 1e9+7; const int sq = 0; vi graph[mx], rgraph[mx]; int dp[mx]; bool busy[mx], vis[mx]; vi nd; void dfs(int node){ vis[node] = 1; //cout << node << endl; for(int adj : rgraph[node]){ if(vis[adj])continue; //dp[adj] = max(dp[adj], dp[node]+1); dfs(adj); } nd.pb(node); } /* bool compare(const int &a, const int &b){ return dp[a] > dp[b]; } */ void run_case(){ int n, m, q;cin >> n >> m >> q; while(m--){ int a, b;cin >> a >> b; graph[a].pb(b); rgraph[b].pb(a); } while(q--){ int node;cin >> node; int k;cin >> k; vi v; for(int i = 0; i < k;i++){ int a;cin >> a; busy[a] = 1; v.pb(a); } if(k < sq){ } else{ int ans = -1; memset(dp, 0, sizeof dp); memset(vis, 0, sizeof vis); nd.clear(); dfs(node); reverse(all(nd)); for(int x : nd){ for(int adj : rgraph[x]){ dp[adj] = max(dp[adj], dp[x]+1); } } for(int i = 1; i <= node;i++){ if(busy[i])continue; //cout << dp[i] << " "; ans = max(ans, dp[i]); } //cout << endl; cout << ans << endl; } for(int i = 0; i < k;i++){ busy[v[i]] = 0; } } } int main(){ speed; int t; //cin >> t; t = 1; while(t--){ run_case(); } } /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! Your Guide when stuck: - Continue keyword only after reading the whole input - Don't use memset with testcases - Check for corner cases(n=1, n=0) - Check where you declare n(Be careful of declaring it globally and in main) */

Compilation message (stderr)

bitaro.cpp: In function 'void usaco_problem()':
bitaro.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen("milkvisits.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen("milkvisits.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp: In function 'void init()':
bitaro.cpp:40:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:42:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...