Submission #567411

#TimeUsernameProblemLanguageResultExecution timeMemory
567411almothana05Bitaro’s Party (JOI18_bitaro)C++14
14 / 100
157 ms17556 KiB
#include<bits/stdc++.h> #define mod 1000000007 #define inf 100000000000000000 using namespace std; long long dis[200000] , ind[200000] , vis[200000]; int trans[200000]; vector<long long>fater[200000]; queue<long long>q; void dfs(long long x){ vis[x] = 1; for(long long i = 0 ; i < fater[x].size() ; i++){ long long fa = fater[x][i]; ind[fa]++; if(vis[fa] == 0){ dfs(fa); } } } int main(){ for(int i = 0 ; i < 200000 ; i++){ dis[i] = -1; } // ios_base::sync_with_stdio(false); // cin.tie(NULL); long long menge , numm , nummer , ed , que; cin >> menge >> ed >> que; for(long long i = 0 ; i < ed ; i++){ cin >> numm >> nummer; fater[nummer].push_back(numm); // ind[numm]++; } cin >> numm; dfs(numm); q.push(numm); dis[numm] = 0; while(q.size()){ long long jet = q.front(); q.pop(); // cout << jet << ' '; for(long long i = 0 ; i < fater[jet].size() ; i++){ long long fa = fater[jet][i]; ind[fa]--; dis[fa] = max(dis[fa] , dis[jet] + 1); if(ind[fa] == 0){ q.push(fa); } } } // cout << "\n"; // for(long long i = 0 ; i <= menge ; i++){ // cout << dis[i] << ' '; // } // cout << "\n"; for(int i = 1; i <= menge ; i++){ assert(ind[i] == 0); } long long erg = -1; cin >> nummer; for(long long i = 0 ; i < nummer ; i++){ cin >> ed; trans[ed] = 1; } for(long long i = numm ; i >= 1 ; i--){ if(trans[i] != 1){ erg = max(erg , dis[i]); } } cout << erg << "\n"; }

Compilation message (stderr)

bitaro.cpp: In function 'void dfs(long long int)':
bitaro.cpp:11:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |    for(long long i = 0 ; i < fater[x].size() ; i++){
      |                          ~~^~~~~~~~~~~~~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:41:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |      for(long long i = 0 ; i < fater[jet].size() ; i++){
      |                            ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...