Submission #573225

# Submission time Handle Problem Language Result Execution time Memory
573225 2022-06-06T09:27:51 Z MohamedFaresNebili Stranded Far From Home (BOI22_island) C++14
10 / 100
1000 ms 14584 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;
        using vi = vector<int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define int ll

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

        int N, M, S[200001];
        vector<int> adj[200001];

        int32_t main() {
            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            cin >> N >> M; int R = 0; string res(N, '0');
            for(int l = 1; l <= N; l++)
                cin >> S[l], R += S[l];
            for(int l = 0; l < M; l++) {
                int U, V; cin >> U >> V;
                adj[U].pb(V); adj[V].pb(U);
            }
            for(int l = 1; l <= N; l++) {
                int curr = 0;
                priority_queue<ii, vector<ii>, greater<ii>> pq;
                pq.push({0, l}); vector<bool> vis(N + 1, 0);
                while(!pq.empty()) {
                    int A = pq.top().second, B = pq.top().first; pq.pop();
                    if(vis[A] || (S[A] > curr && A != l)) continue;
                    vis[A] = 1; curr += S[A];
                    for(auto E : adj[A]) {
                        if(vis[E]) continue;
                        pq.push({S[E], E});
                    }
                }
                if(curr == R) res[l - 1] = '1';
            }
            cout << res << "\n";
        }


























Compilation message

island.cpp: In function 'int32_t main()':
island.cpp:38:46: warning: unused variable 'B' [-Wunused-variable]
   38 |                     int A = pq.top().second, B = pq.top().first; pq.pop();
      |                                              ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 193 ms 5076 KB Output is correct
5 Correct 137 ms 5104 KB Output is correct
6 Correct 257 ms 5108 KB Output is correct
7 Correct 197 ms 5076 KB Output is correct
8 Correct 157 ms 5100 KB Output is correct
9 Correct 233 ms 5120 KB Output is correct
10 Correct 63 ms 5088 KB Output is correct
11 Correct 61 ms 5076 KB Output is correct
12 Correct 67 ms 5112 KB Output is correct
13 Correct 108 ms 5088 KB Output is correct
14 Correct 88 ms 5100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4968 KB Output is correct
3 Execution timed out 1083 ms 14584 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1091 ms 13072 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1094 ms 14152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 193 ms 5076 KB Output is correct
5 Correct 137 ms 5104 KB Output is correct
6 Correct 257 ms 5108 KB Output is correct
7 Correct 197 ms 5076 KB Output is correct
8 Correct 157 ms 5100 KB Output is correct
9 Correct 233 ms 5120 KB Output is correct
10 Correct 63 ms 5088 KB Output is correct
11 Correct 61 ms 5076 KB Output is correct
12 Correct 67 ms 5112 KB Output is correct
13 Correct 108 ms 5088 KB Output is correct
14 Correct 88 ms 5100 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 2 ms 4968 KB Output is correct
17 Execution timed out 1083 ms 14584 KB Time limit exceeded
18 Halted 0 ms 0 KB -