Submission #823809

# Submission time Handle Problem Language Result Execution time Memory
823809 2023-08-13T07:15:34 Z Amylopectin Stranded Far From Home (BOI22_island) C++14
10 / 100
1000 ms 34780 KB
#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

island.cpp: In function 'int main()':
island.cpp:49:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for(j=0; j<pat[cn].size(); j++)
      |                      ~^~~~~~~~~~~~~~~
island.cpp:21:32: warning: unused variable 'fm' [-Wunused-variable]
   21 |     long long i,j,n,m,cn,cm,fn,fm,cou,cva;
      |                                ^~
island.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%lld %lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
island.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%lld",&npop[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
island.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%lld %lld",&cn,&cm);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23764 KB Output is correct
2 Correct 10 ms 23768 KB Output is correct
3 Correct 10 ms 23804 KB Output is correct
4 Correct 160 ms 23900 KB Output is correct
5 Correct 152 ms 23892 KB Output is correct
6 Correct 121 ms 23892 KB Output is correct
7 Correct 161 ms 23900 KB Output is correct
8 Correct 115 ms 23892 KB Output is correct
9 Correct 115 ms 23924 KB Output is correct
10 Correct 64 ms 23888 KB Output is correct
11 Correct 61 ms 23872 KB Output is correct
12 Correct 60 ms 23896 KB Output is correct
13 Correct 99 ms 23876 KB Output is correct
14 Correct 84 ms 23896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23808 KB Output is correct
2 Correct 10 ms 23764 KB Output is correct
3 Execution timed out 1055 ms 34780 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23764 KB Output is correct
2 Execution timed out 1066 ms 33084 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23764 KB Output is correct
2 Execution timed out 1074 ms 34420 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23764 KB Output is correct
2 Correct 10 ms 23768 KB Output is correct
3 Correct 10 ms 23804 KB Output is correct
4 Correct 160 ms 23900 KB Output is correct
5 Correct 152 ms 23892 KB Output is correct
6 Correct 121 ms 23892 KB Output is correct
7 Correct 161 ms 23900 KB Output is correct
8 Correct 115 ms 23892 KB Output is correct
9 Correct 115 ms 23924 KB Output is correct
10 Correct 64 ms 23888 KB Output is correct
11 Correct 61 ms 23872 KB Output is correct
12 Correct 60 ms 23896 KB Output is correct
13 Correct 99 ms 23876 KB Output is correct
14 Correct 84 ms 23896 KB Output is correct
15 Correct 10 ms 23808 KB Output is correct
16 Correct 10 ms 23764 KB Output is correct
17 Execution timed out 1055 ms 34780 KB Time limit exceeded
18 Halted 0 ms 0 KB -