답안 #592639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592639 2022-07-09T11:52:27 Z 1zaid1 Stranded Far From Home (BOI22_island) C++17
0 / 100
8 ms 9684 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<200005> vis;
int p[M], n, d[M];

struct in{int a;};
bool operator<(in a, in b) {return p[a.a] > p[b.a];}
bool bfs(int s) {
    for (int i = 1; i <= n; i++) d[i] = vis[i] = 0;
    int sum = 0;
    priority_queue<in> q;
    vis[s] = 1;
    q.push({s});
    while (!q.empty()) {
        auto [t] = q.top(); q.pop();
        if (t != s && p[t] > sum) {
            return 0;
        } else sum += p[t];
        for (int i:node[t]) {
            if (!vis[i]) {
                vis[i] = 1;
                q.push({i});
            }
        }
    }
 
    return true;
}

void dfs(int s) {
    vis[s] = true;
    for (int i:node[s]) {
        if (!vis[i]) {
            dfs(i);
        }
    }


}
 
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;
    cout << string(n-1, '1') << 0 << endl;
 
    return 0;
}
/*
4 3
4 2 2 1
1 2
3 2
4 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Incorrect 5 ms 9684 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 9684 KB Output isn't correct
2 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 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -