# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
589941 | 2022-07-05T12:09:42 Z | 1zaid1 | Stranded Far From Home (BOI22_island) | C++17 | 1000 ms | 42468 KB |
#include <bits/stdc++.h> using namespace std; #define endl '\n' const int M = 4e5+1; #define int long long vector<int> node[M]; bitset<100005> vis; int p[M], n, d[M]; bool bfs(int s) { for (int i = 1; i <= n; i++) d[i] = vis[i] = 0; int sum = p[s]; priority_queue<int, vector<int>, greater<int>> q; vis[s] = 1; q.push(s); while (!q.empty()) { int t = q.top(); q.pop(); for (int i:node[t]) { if (!vis[i]) { if (p[i] > sum) return 0; sum += p[i]; vis[i] = 1; q.push(i); } } } for (int i = 1; i <= n; i++) if (!vis[i]) return 0; return true; } signed main() { cin.tie(0)->sync_with_stdio(0); int m; cin >> n >> m; for (int i = 1; i <= n; i++) cin >> p[i]; for (int i = 1; i <= m; i++) { int a, b; cin >> a >> b; node[a].push_back(b); node[b].push_back(a); } for (int i = 1; i <= n; i++) sort(node[i].begin(), node[i].end(),[](int a, int b) {return p[a] < p[b];}); for (int i = 1; i <= n; i++) cout << bfs(i); cout << endl; return 0; } /* 4 4 2 2 4 3 1 2 1 3 2 3 3 4 4 3 4 2 2 1 1 2 3 2 4 1 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 9684 KB | Output is correct |
2 | Correct | 5 ms | 9700 KB | Output is correct |
3 | Correct | 5 ms | 9724 KB | Output is correct |
4 | Incorrect | 134 ms | 9812 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Correct | 5 ms | 9684 KB | Output is correct |
3 | Runtime error | 415 ms | 42236 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Execution timed out | 1070 ms | 22324 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 9812 KB | Output is correct |
2 | Runtime error | 407 ms | 42468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 9684 KB | Output is correct |
2 | Correct | 5 ms | 9700 KB | Output is correct |
3 | Correct | 5 ms | 9724 KB | Output is correct |
4 | Incorrect | 134 ms | 9812 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |