Submission #751498

#TimeUsernameProblemLanguageResultExecution timeMemory
751498Valters07Bitaro’s Party (JOI18_bitaro)C++14
0 / 100
9 ms5420 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5+5; vector<int> g[N]; vector<pair<int,int> > best[N]; int main() { fio // ifstream cin("in.in"); int n, m, q; cin >> n >> m >> q; int B = sqrt(n)+1; while(m--) { int u, v; cin >> u >> v; g[v].pb(u); } for(int i = 1;i<=n;i++) best[i].pb({0,i}); for(int i = 1;i<=n;i++) { map<int,int> mp; for(auto j:g[i]) for(auto x:best[j]) mp[x.se]=max(mp[x.se],x.fi+1); for(auto x:mp) best[i].pb({x.se,x.fi}); sort(best[i].begin(),best[i].end(),greater<pair<int,int> >()); while(best[i].size()>B) best[i].pop_back(); } for(int qi = 1;qi<=q;qi++) { int f, y; cin >> f >> y; vector<int> del(y); for(auto &x:del) cin >> x; if(y<B) { set<int> s; for(auto x:del) s.insert(x); auto t = --best[f].end(); while(t!=best[f].begin()&&s.count((*t).se)) t--; if(s.count((*t).se)) cout << -1; else cout << (*t).fi; } else { vector<int> dist(n+1); for(auto x:del) dist[x]=-1e9; for(int i = 1;i<=f;i++) for(auto j:g[i]) dist[j]=max(dist[j],dist[i]+1); if(dist[f]<0) cout << -1; else cout << dist[f]; } cout << "\n"; } // cin.close(); return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:39:29: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         while(best[i].size()>B)
      |               ~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...