Submission #603479

#TimeUsernameProblemLanguageResultExecution timeMemory
603479almothana05Stranded Far From Home (BOI22_island)C++14
0 / 100
1067 ms26624 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; queue<int>q; priority_queue<pair<int, int> >pri; vector<int>gr[200000]; int num[200000] , vis[200000]; int main(){ int menge , numm = 0, nummer , ed; cin >> menge >> ed; for(int i = 0 ;i < menge ; i++){ cin >> numm; num[i + 1] = numm; } for(int i = 0 ; i< ed ; i++){ cin >> numm >> nummer; gr[numm].push_back(nummer); gr[nummer].push_back(numm); } for(int i = 1 ; i <= menge ; i++){ int fl = 1; int cmp = 0; vis[i] = 1; q.push(i); while(q.size()){ int jet = q.front(); q.pop(); cmp += num[jet]; for(int i = 0 ; i < gr[jet].size() ; i++){ int kind = gr[jet][i]; pri.push({-num[kind] , kind }); } while(pri.size() && -pri.top().first <= cmp){ if(vis[pri.top().second] == 0){ vis[pri.top().second] = 1; q.push(pri.top().second); } pri.pop(); } } while(pri.size()){ pri.pop(); } for(int j = 1 ; j <=menge ; j++){ if(vis[j] == 0){ fl = 0; } vis[j] = 0; } cout << fl ; } }

Compilation message (stderr)

island.cpp: In function 'int main()':
island.cpp:29:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for(int i = 0 ; i < gr[jet].size() ; i++){
      |                             ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...