답안 #654403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654403 2022-10-31T08:55:05 Z atigun Stranded Far From Home (BOI22_island) C++14
10 / 100
414 ms 724 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 2e3;

int n, m;
vector<ll> a(maxn+5);
vector<vector<int>> g(maxn+5);
vector<bool> vis(maxn+5, 0);

bool test(int V){
  for(int i = 0; i < maxn+5; i++)
    vis[i] = 0;
  priority_queue<array<ll, 2>, vector<array<ll, 2>>, greater<array<ll, 2>>> PQ;
  int took = 0;
  ll curr_size = 0;
  PQ.push({0, V});
  while(!PQ.empty()){
    int v = PQ.top()[1];
    PQ.pop();
    if(vis[v])
      continue;
    vis[v] = 1;
    if(V!=v && a[v] > curr_size){
      return 0;
    }
    took++;
    curr_size+= a[v];
    for(int u : g[v]){
      if(!vis[u]){
        PQ.push({a[u], u});
      }
    }
  }
  return (took == n);
}

void solve(){
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i = 1; i <= n; i++)
    cout << test(i);
  cout << "\n";
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  // cin >> tt;
  while(tt--){
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 259 ms 340 KB Output is correct
5 Correct 170 ms 432 KB Output is correct
6 Correct 414 ms 444 KB Output is correct
7 Correct 234 ms 564 KB Output is correct
8 Correct 182 ms 340 KB Output is correct
9 Correct 310 ms 468 KB Output is correct
10 Correct 95 ms 424 KB Output is correct
11 Correct 88 ms 420 KB Output is correct
12 Correct 96 ms 424 KB Output is correct
13 Correct 168 ms 428 KB Output is correct
14 Correct 106 ms 428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 4 ms 724 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 4 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 6 ms 708 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 259 ms 340 KB Output is correct
5 Correct 170 ms 432 KB Output is correct
6 Correct 414 ms 444 KB Output is correct
7 Correct 234 ms 564 KB Output is correct
8 Correct 182 ms 340 KB Output is correct
9 Correct 310 ms 468 KB Output is correct
10 Correct 95 ms 424 KB Output is correct
11 Correct 88 ms 420 KB Output is correct
12 Correct 96 ms 424 KB Output is correct
13 Correct 168 ms 428 KB Output is correct
14 Correct 106 ms 428 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Runtime error 4 ms 724 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -