Submission #95073

#TimeUsernameProblemLanguageResultExecution timeMemory
95073omidazadiBitaro’s Party (JOI18_bitaro)C++14
0 / 100
14 ms8956 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pll pair <ll , ll> #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define mp make_pair #define X first #define Y second #define LB(x) ((x) & -(x)) #define BIT(x , y) (((x) >> (y)) & 1) #define ll int const ll MAXN=1e5+10; const ll SQ=1e2+10; vector <pll> e[MAXN]; vector <ll> in[MAXN]; vector <ll> out[MAXN]; ll z[MAXN]; ll dp[MAXN]; int main() { ios_base :: sync_with_stdio(false); cin.tie(0); ll n , m , q; cin>>n>>m>>q; for(ll i=1;i<=m;i++) { ll v , u; cin>>v>>u; out[v].pb(u); in[u].pb(v); } for(ll i=1;i<=n;i++) { for(ll j=0;j<in[i].size();j++) { ll v=in[i][j]; for(ll u=0;u<e[v].size();u++) { e[i].pb(mp(e[v][u].X+1 , e[v][u].Y)); } } sort(e[i].begin() , e[i].end() , std::greater<pll>()); while (e[i].size()>SQ) { e[i].pob(); } if (e[i].size()<SQ) { e[i].pb(mp(0 , i)); } } for(ll i=1;i<=q;i++) { ll t , y; cin>>t>>y; for(ll j=1;j<=y;j++) { ll x; cin>>x; z[x]=i; } if (y>=SQ) { ll res=-1; for(ll j=t;j>=1;j--) { dp[j]=(j==t ? 0 : -1); for(ll u=0;u<out[j].size() && out[j][u]<=t;u++) { if (dp[out[j][u]]!=-1) { dp[j]=max(dp[j] , dp[out[j][u]]+1); } } if (z[j]!=i) { res=max(res , dp[j]); } } cout<<res<<endl; } else { bool flag=false; for(ll j=0;j<e[t].size();j++) { if (z[e[t][j].Y]!=i) { cout<<e[t][j].X<<endl; flag=true; break; } } if (!flag) { cout<<-1<<endl; } } } }

Compilation message (stderr)

bitaro.cpp:21:0: warning: "ll" redefined
 #define ll int
 
bitaro.cpp:5:0: note: this is the location of the previous definition
 #define ll long long
 
bitaro.cpp: In function 'int main()':
bitaro.cpp:52:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll j=0;j<in[i].size();j++)
              ~^~~~~~~~~~~~~
bitaro.cpp:56:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(ll u=0;u<e[v].size();u++)
               ~^~~~~~~~~~~~
bitaro.cpp:96:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll u=0;u<out[j].size() && out[j][u]<=t;u++)
                ~^~~~~~~~~~~~~~
bitaro.cpp:116:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(ll j=0;j<e[t].size();j++)
               ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...