Submission #290483

#TimeUsernameProblemLanguageResultExecution timeMemory
290483wwddBitaro’s Party (JOI18_bitaro)C++14
7 / 100
2086 ms8132 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> ii; typedef pair<ii,int> ti; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<vi> vvi; const int SQ = 320; const int MN = 100010; vii go[MN]; vvi g; int dp[MN]; bitset<MN> bs; int sad(int u, vi& no) { for(auto& it: no) { bs.set(it); } for(int i=0;i<go[u].size();i++) { int v = go[u][i].second; if(!bs[v]) { for(auto& it: no) { bs.reset(it); } return go[u][i].first; } } fill(begin(dp),end(dp),-1e9); dp[u] = 0; for(int i=u;i>=0;i--) { for(int j=0;j<g[i].size();j++) { int v = g[i][j]; dp[v] = max(dp[v],dp[i]+1); } } int res = -1; for(int i=0;i<=u;i++) { if(!bs[i]) { res = max(res,dp[i]); } } for(auto& it: no) { bs.reset(it); } return res; } int main() { ios::sync_with_stdio(0);cin.tie(0); int n,m,q; cin >> n >> m >> q; g.assign(n,vi()); for(int i=0;i<m;i++) { int a,b; cin >> a >> b; a--;b--; g[b].push_back(a); } for(int i=0;i<n;i++) { priority_queue<ti> bo; for(int j=0;j<g[i].size();j++) { int u = g[i][j]; bo.push({{go[u].front().first,0},u}); } while(!bo.empty() && go[i].size() < SQ) { ti ol = bo.top();bo.pop(); int u = ol.second; ii co = ol.first; int idx = co.second; ii ens = go[u][idx]; ens.first++; if(!bs[ens.second]) { bs.set(ens.second); go[i].push_back(ens); } idx++; if(idx < go[u].size()) { bo.push({{go[u][idx].first,idx},u}); } } if(go[i].size() < SQ) { go[i].push_back({0,i}); } for(auto& it: go[i]) { bs.reset(it.second); } } for(int i=0;i<q;i++) { int tr,lo; cin >> tr >> lo; vi no; tr--; for(int j=0;j<lo;j++) { int t; cin >> t; t--; no.push_back(t); } cout << sad(tr,no) << '\n'; } }

Compilation message (stderr)

bitaro.cpp: In function 'int sad(int, vi&)':
bitaro.cpp:19:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for(int i=0;i<go[u].size();i++) {
      |              ~^~~~~~~~~~~~~
bitaro.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int j=0;j<g[i].size();j++) {
      |               ~^~~~~~~~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:60:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   for(int j=0;j<g[i].size();j++) {
      |               ~^~~~~~~~~~~~
bitaro.cpp:76:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |    if(idx < go[u].size()) {
      |       ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...