Submission #987817

#TimeUsernameProblemLanguageResultExecution timeMemory
987817goduadzesabaBitaro’s Party (JOI18_bitaro)C++17
100 / 100
1236 ms499496 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=2e5+5,B=300; int n,m,q,x,y,z,dp[N],mp[N],bd[N]; vector <int> v[N],rv[N]; vector <pair<int,int> > b[N],t; bool bl; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m>>q; while (m--){ cin>>x>>y; v[x].push_back(y); rv[y].push_back(x); } for (int i=1; i<=n; i++){ b[i].push_back({0,i}); for (int j:rv[i]){ t.clear(); x=0; y=0; while (t.size()<B && (x<b[i].size() || y<b[j].size())){ if (x<b[i].size() && (y==b[j].size() || b[i][x].first>=b[j][y].first+1)){ z=b[i][x].first; //for (x; x<b[i].size() && b[i][x].first==z; x++){ if (mp[b[i][x].second]==0){ t.push_back(b[i][x]); mp[b[i][x].second]=1; }x++; //} } else if (y<b[j].size() && (x==b[i].size() || b[i][x].first<=b[j][y].first+1)){ z=b[j][y].first; //for (y; y<b[j].size() && b[j][y].first==z; y++){ if (mp[b[j][y].second]==0){ t.push_back({b[j][y].first+1,b[j][y].second}); mp[b[j][y].second]=1; }y++; //} } } b[i]=t; for (auto i:t) mp[i.second]=0; } } while (q--){ cin>>x>>m; vector <int> bad; for (int i=1; i<=m; i++){ cin>>y; bd[y]=1; bad.push_back(y); } if (m<B){ bl=0; for (auto i:b[x]){ if (bd[i.second]==0){ cout<<i.first<<"\n"; bl=1; break; } } if (bl==0) cout<<-1<<"\n"; } else{ for (int i=1; i<=x; i++){ if (bd[i]==1) dp[i]=-1e9; else dp[i]=0; for (int j:rv[i]){ dp[i]=max(dp[i],dp[j]+1); } } cout<<max(dp[x],-1LL)<<"\n"; } for (int i:bad) bd[i]=0; } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:22:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |            while (t.size()<B && (x<b[i].size() || y<b[j].size())){
      |                                  ~^~~~~~~~~~~~
bitaro.cpp:22:52: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |            while (t.size()<B && (x<b[i].size() || y<b[j].size())){
      |                                                   ~^~~~~~~~~~~~
bitaro.cpp:23:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                if (x<b[i].size() && (y==b[j].size() || b[i][x].first>=b[j][y].first+1)){
      |                    ~^~~~~~~~~~~~
bitaro.cpp:23:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                if (x<b[i].size() && (y==b[j].size() || b[i][x].first>=b[j][y].first+1)){
      |                                      ~^~~~~~~~~~~~~
bitaro.cpp:32:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                else if (y<b[j].size() && (x==b[i].size() || b[i][x].first<=b[j][y].first+1)){
      |                         ~^~~~~~~~~~~~
bitaro.cpp:32:44: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                else if (y<b[j].size() && (x==b[i].size() || b[i][x].first<=b[j][y].first+1)){
      |                                           ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...