# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
755667 | VadimK | Stranded Far From Home (BOI22_island) | C++17 | 1076 ms | 25408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
string ans="";
int s[n+1];
vector <int> 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<int,int> > q;
for (int i=1; i<=n; i++)
{
int total=s[i];
int 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;
}
컴파일 시 표준 에러 (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... |