Submission #820060

#TimeUsernameProblemLanguageResultExecution timeMemory
820060smirichtoBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2083 ms11976 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pi pair<ll,ll> #define F first #define S second #define all(x) (x).begin(), (x).end() #define alll(x) ((x).begin()+1), (x).end() #define clean(v) (v).resize(distance((v).begin(), unique(all(v)))); #define yes cout<<"Yes"<<endl; #define no cout<<"No"<<endl; #define mod mod #define endl '\n' mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 998244353; void io() { ios::sync_with_stdio(false); cin.tie(NULL); } template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } void nop() { cout << -1 << endl; return; } const int N = 1e5+5 , B = 350 ; vector<int> adj[N] ; vector<pi> best[N] ; vector<pi> merge(vector<pi> a , vector<pi> b) { vector<pi> tmp ; for(auto p : b) a.pb({p.F+1 , p.S}) ; sort(all(a)) ; reverse(all(a)) ; map<int,int> vis ; for(auto p : a){ if(vis[p.S]) continue; vis[p.S] = 1 ; tmp.pb(p) ; if(tmp.size()>B+3) break ; } return tmp ; } map<int,int> marked ; int ans ; void work(int t , int dep) { if(!marked[t]) ckmax(ans , dep) ; for(int to : adj[t]) work(to , dep+1) ; } void solve() { int n , m , q ; cin>>n>>m>>q ; for(int i = 1 ; i<=m ; i++){ int u , v ; cin>>u>>v ; adj[v].pb(u) ; } for(int i = 1 ; i<=n ; i++){ best[i].pb({0 , i}) ; for(int to : adj[i]){ best[i] = merge(best[i] , best[to]) ; } } while(q--){ int t , y ; cin>>t>>y ; marked.clear() ; for(int i = 1 ; i<=y ; i++){ int x ; cin>>x ; marked[x] = 1 ; } ans = -1 ; if(y<=B){ for(int i = 0 ; i<best[t].size() ; i++){ if(!marked[best[t][i].S]){ ans = best[t][i].F ; break ; } } } else{ work(t , 0) ; } cout<<ans<<endl; } } int main() { io(); ll tt = 1; //cin>>tt ; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void solve()':
bitaro.cpp:90:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for(int i = 0 ; i<best[t].size() ; i++){
      |                             ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...