Submission #1103452

#TimeUsernameProblemLanguageResultExecution timeMemory
1103452trandangquangBitaro’s Party (JOI18_bitaro)C++14
0 / 100
6 ms6992 KiB
#include <bits/stdc++.h> using namespace std; #define task "test" #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define sz(a) (int)(a).size() #define all(a) (a).begin(), (a).end() #define bit(s, i) (((s) >> (i)) & 1) #define ii pair <int, int> #define fi first #define se second #define ll long long #define eb emplace_back #define pb push_back #define __builtin_popcount __builtin_popcountll void solve(); int32_t main() { if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); solve(); } const int N=1e5+5; const int B=300; const int INF=1e9; int n, m, q, ban[N], dp[N]; vector<int>adj[N]; vector<ii> largest[N]; void solve() { cin>>n>>m>>q; FOR(i,1,m){ int a,b; cin>>a>>b; adj[b].eb(a); } FOR(i,1,n){ for(int j:adj[i]){ vector<ii>a=largest[j]; a.eb(0,j); vector<ii>b(sz(a)+sz(largest[i])); merge(all(a),all(largest[i]),b.begin(),greater<ii>()); // b.erase(unique(all(b)),b.end()); while(sz(b)>B) b.pop_back(); largest[i]=b; } for(ii &j:largest[i]) ++j.fi; } // FOR(i,1,n){ // for(ii j:largest[i])cout<<j.se<<" "; // cout<<'\n'; // } memset(dp,-0x3f,sizeof(dp)); FOR(i,1,q){ int t,y; cin>>t>>y; vector<int>c(y); for(int &j:c) { cin>>j; ban[j]=true; } if(y<sz(largest[t])){ int mx=0; for(ii j:largest[t]){ if(!ban[j.se]){ mx=max(mx,j.fi); } } cout<<mx; } else{ for(int j:c) dp[j]=-INF; FOR(j,1,t) if(!ban[j]) { dp[j]=0; for(int k:adj[j]) if(!ban[k]){ dp[j]=max(dp[j],dp[k])+1; } } if(dp[t]<=-INF) cout<<-1; else cout<<dp[t]; } cout<<'\n'; for(int j:c) ban[j]=false; } }

Compilation message (stderr)

bitaro.cpp: In function 'int32_t main()':
bitaro.cpp:23:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:24:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...