# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
589862 | 1zaid1 | Stranded Far From Home (BOI22_island) | C++17 | 44 ms | 888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int M = 4e3+1;
#define int long long
vector<int> node[M];
int p[M];
bool bfs(int s) {
bitset<100005> vis;
int sum = p[s];
queue<int> q;
vis[s] = 1;
q.push(s);
while (!q.empty()) {
int t = q.front(); 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);
}
}
} return true;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, 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
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |