# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
823809 | Amylopectin | Stranded Far From Home (BOI22_island) | C++14 | 1074 ms | 34780 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const long long mxn = 1e6 + 10;
struct we
{
long long noo,cva;
bool operator() (const struct we &l,const struct we &r)
{
return l.cva > r.cva;
}
};
long long npop[mxn] = {},u[mxn] = {};
char ans[mxn] = {};
priority_queue<struct we,vector<struct we>,struct we> qu;
vector<long long> pat[mxn] = {};
int main()
{
long long i,j,n,m,cn,cm,fn,fm,cou,cva;
scanf("%lld %lld",&n,&m);
for(i=1; i<=n; i++)
{
scanf("%lld",&npop[i]);
}
for(i=0; i<m; i++)
{
scanf("%lld %lld",&cn,&cm);
pat[cn].push_back(cm);
pat[cm].push_back(cn);
}
for(i=1; i<=n; i++)
{
qu.push({i,npop[i]});
u[i] = i;
cou = 0;
cva = 0;
while(!qu.empty())
{
cn = qu.top().noo;
qu.pop();
if(cou > 0 && cva < npop[cn])
{
break;
}
cou ++;
cva += npop[cn];
for(j=0; j<pat[cn].size(); j++)
{
fn = pat[cn][j];
if(u[fn] != i)
{
qu.push({fn,npop[fn]});
u[fn] = i;
}
}
}
while(!qu.empty())
{
qu.pop();
}
if(cou == n)
{
ans[i-1] = '1';
}
else
{
ans[i-1] = '0';
}
}
printf("%s\n",ans);
}
Compilation message (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... |