Submission #987652

#TimeUsernameProblemLanguageResultExecution timeMemory
987652goduadzesabaBitaro’s Party (JOI18_bitaro)C++17
0 / 100
10 ms8028 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=1e5+5,B=400; int n,m,q,x,y,z,dp[N]; vector <int> v[N],rv[N]; vector <pair<int,int> > b[N],t; map <int,bool> mp,bd; 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; mp.clear(); while (t.size()<B && (x<b[i].size() || y<b[j].size())){ if (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; } } } if (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; } } } } b[i]=t; } } while (q--){ cin>>x>>m; bd.clear(); for (int i=1; i<=m; i++){ cin>>y; bd[y]=1; } 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]=-1; continue;} dp[i]=0; for (int j:rv[i]){ dp[i]=max(dp[i],dp[j]+1); } } cout<<dp[x]<<"\n"; } } }

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 (y==b[j].size() || b[i][x].first>=b[j][y].first+1){
      |                    ~^~~~~~~~~~~~~
bitaro.cpp:25:26: warning: statement has no effect [-Wunused-value]
   25 |                     for (x; x<b[i].size() && b[i][x].first==z; x++){
      |                          ^
bitaro.cpp:25:30: 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]
   25 |                     for (x; x<b[i].size() && b[i][x].first==z; x++){
      |                             ~^~~~~~~~~~~~
bitaro.cpp:31: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]
   31 |                if (x==b[i].size() || b[i][x].first<=b[j][y].first+1){
      |                    ~^~~~~~~~~~~~~
bitaro.cpp:33:26: warning: statement has no effect [-Wunused-value]
   33 |                     for (y; y<b[j].size() && b[j][y].first==z; y++){
      |                          ^
bitaro.cpp:33:30: 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]
   33 |                     for (y; y<b[j].size() && b[j][y].first==z; y++){
      |                             ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...