답안 #604003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604003 2022-07-24T15:05:29 Z Ahmadsm2005 Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 17356 KB
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int N,M,V[200001],X,Y,VIS[200001];
int R[200001],R2[200001];
vector<int>edges[200001];
void BFS(int X){
    for(int i = 0; i < N; i += 1)VIS[i] = 0;
    priority_queue<pair<int,int>>Q;
    int CNT = V[X];
    Q.push({0,X});
    vector<int>UU;
    while(Q.size()){
        int F = Q.top().second,S = -Q.top().first;
        Q.pop();
        if(VIS[F])continue;
        if((S > CNT) || (R[F] == 0 && R2[F] >= CNT)){
            R[X] = 0;
            R2[X] = CNT;
            return;
        }
        if(R[F] == 1)break;
        VIS[F] = 1;
        CNT += S;
        CNT = min(CNT,(int)1e9);
        for(int i = 0; i < edges[F].size(); i += 1){
            Q.push({-V[edges[F][i]],edges[F][i]});
        }
    }
    R[X] = 1;
}
int32_t main()
{
    cin.tie(0),iostream::sync_with_stdio(0);
    cin>>N>>M;
    vector<int>RR;
    vector<pair<int,int>>FF;
    for(int i = 0; i < N; i += 1){
        cin>>V[i];
        FF.push_back({V[i],i});
        R[i] = -1;
    }
    sort(FF.rbegin(),FF.rend());
    for(int i = 0; i < M; i += 1){
        cin>>X>>Y;
        edges[X - 1].push_back(Y - 1),edges[Y - 1].push_back(X - 1);
    }
    for(int i = 0; i < N; i += 1){
        BFS(FF[i].second);
    }
    for(int i = 0; i < N; i += 1)cout<<R[i];
}

Compilation message

island.cpp: In function 'void BFS(int)':
island.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i = 0; i < edges[F].size(); i += 1){
      |                        ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 123 ms 5148 KB Output is correct
5 Correct 26 ms 5144 KB Output is correct
6 Correct 5 ms 5076 KB Output is correct
7 Correct 124 ms 5076 KB Output is correct
8 Correct 100 ms 5112 KB Output is correct
9 Correct 146 ms 5152 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 5 ms 5152 KB Output is correct
12 Correct 5 ms 5152 KB Output is correct
13 Correct 5 ms 5076 KB Output is correct
14 Correct 26 ms 5076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Execution timed out 1095 ms 17356 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1078 ms 15424 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 1090 ms 15324 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 123 ms 5148 KB Output is correct
5 Correct 26 ms 5144 KB Output is correct
6 Correct 5 ms 5076 KB Output is correct
7 Correct 124 ms 5076 KB Output is correct
8 Correct 100 ms 5112 KB Output is correct
9 Correct 146 ms 5152 KB Output is correct
10 Correct 6 ms 5076 KB Output is correct
11 Correct 5 ms 5152 KB Output is correct
12 Correct 5 ms 5152 KB Output is correct
13 Correct 5 ms 5076 KB Output is correct
14 Correct 26 ms 5076 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Execution timed out 1095 ms 17356 KB Time limit exceeded
18 Halted 0 ms 0 KB -