# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
601467 | 2022-07-22T04:51:40 Z | 반딧불(#8472) | Stranded Far From Home (BOI22_island) | C++17 | 1000 ms | 16036 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; int arr[200002]; bool ans[200002]; bool chk[200002]; vector<int> link[200002]; bool dfs(int st){ priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; for(int i=1; i<=n; i++) chk[i] = 0; chk[st] = 1; int sum = arr[st]; for(auto y: link[st]) pq.push(make_pair(arr[y], y)), chk[y] = 1; while(!pq.empty()){ pair<int, int> tmp = pq.top(); pq.pop(); int x = tmp.second; if(sum < tmp.first) return false; sum += tmp.first; if(sum >= 1e9) return true; for(auto y: link[x]){ if(chk[y]) continue; pq.push(make_pair(arr[y], y)); chk[y] = 1; } } return true; } int main(){ scanf("%d %d", &n, &m); for(int i=1; i<=n; i++) scanf("%d", &arr[i]); for(int i=1; i<=m; i++){ int x, y; scanf("%d %d", &x, &y); link[x].push_back(y); link[y].push_back(x); } for(int i=1; i<=n; i++) ans[i] = dfs(i); for(int i=1; i<=n; i++) printf("%d", ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4996 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 5 ms | 5204 KB | Output is correct |
5 | Correct | 4 ms | 5076 KB | Output is correct |
6 | Correct | 4 ms | 5076 KB | Output is correct |
7 | Correct | 4 ms | 5076 KB | Output is correct |
8 | Correct | 4 ms | 5016 KB | Output is correct |
9 | Correct | 203 ms | 5100 KB | Output is correct |
10 | Correct | 5 ms | 5016 KB | Output is correct |
11 | Correct | 5 ms | 5048 KB | Output is correct |
12 | Correct | 4 ms | 5076 KB | Output is correct |
13 | Correct | 105 ms | 5076 KB | Output is correct |
14 | Correct | 79 ms | 5076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Execution timed out | 1027 ms | 14696 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Execution timed out | 1049 ms | 16036 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Execution timed out | 1042 ms | 15716 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4996 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 5 ms | 5204 KB | Output is correct |
5 | Correct | 4 ms | 5076 KB | Output is correct |
6 | Correct | 4 ms | 5076 KB | Output is correct |
7 | Correct | 4 ms | 5076 KB | Output is correct |
8 | Correct | 4 ms | 5016 KB | Output is correct |
9 | Correct | 203 ms | 5100 KB | Output is correct |
10 | Correct | 5 ms | 5016 KB | Output is correct |
11 | Correct | 5 ms | 5048 KB | Output is correct |
12 | Correct | 4 ms | 5076 KB | Output is correct |
13 | Correct | 105 ms | 5076 KB | Output is correct |
14 | Correct | 79 ms | 5076 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 2 ms | 4948 KB | Output is correct |
17 | Execution timed out | 1027 ms | 14696 KB | Time limit exceeded |
18 | Halted | 0 ms | 0 KB | - |