답안 #755670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755670 2023-06-10T13:44:46 Z VadimK Stranded Far From Home (BOI22_island) C++17
0 / 100
1000 ms 14608 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    string ans="";
    ll s[n+1];
    vector <ll> g[n+1];
    for (int i=1; i<=n; i++)
        cin>>s[i];
      for (int i=1; i<=m; i++)
      {
          int a,b;
          cin>>a>>b;
          g[a].push_back(b);
          g[b].push_back(a);
      }
      priority_queue <pair<ll,ll> > q;
        for (int i=1; i<=n; i++)
        {
            ll total=s[i];
            ll v,num;
            bool vis[n+1]={0},can=1;
            q.push(make_pair(0,i));
           while (!q.empty())
           {
                tie (num,v)=q.top(); q.pop();
               num*=-1;
               if (total<num) break;
               vis[v]=1;
               total+=num;
              for (int j=0; j<g[v].size(); j++)
               if (!vis[g[v][j]]) q.push(make_pair(-1*s[g[v][j]],g[v][j]));
           }
           for (int x=1; x<=n; x++)
            if (!vis[x]) {ans+='0'; can=0; break;}
            if (can==1) ans+='1';
        }
        cout<<ans;
}

Compilation message

island.cpp: In function 'int main()':
island.cpp:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |               for (int j=0; j<g[v].size(); j++)
      |                             ~^~~~~~~~~~~~
island.cpp:39:12: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |            for (int x=1; x<=n; x++)
      |            ^~~
island.cpp:41:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   41 |             if (can==1) ans+='1';
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 229 ms 428 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Execution timed out 1085 ms 14608 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 1078 ms 12876 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1073 ms 14224 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 229 ms 428 KB Output isn't correct
5 Halted 0 ms 0 KB -