Submission #1069517

# Submission time Handle Problem Language Result Execution time Memory
1069517 2024-08-22T04:47:32 Z Faisal_Saqib Closing Time (IOI23_closing) C++17
0 / 100
60 ms 21844 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpl vector<pll>
const int N=2e5+10;
vpl ma[N];
ll paid[N];
bool vis[N];
int max_score(int n, int x, int y, long long k, std::vector<int> U,std::vector<int> V, std::vector<int> W)
{
    for(int i=0;i<=n;i++)
    {
        ma[i].clear();
        paid[i]=0;
    }
    int m=U.size();
    for(int i=0;i<m;i++)
    {
        ma[U[i]].push_back({W[i],V[i]});
        ma[V[i]].push_back({W[i],U[i]});
    }
    int mx=0;
    {
        for(int i=0;i<=n;i++)vis[i]=0;
        priority_queue<pll,vpl,greater<pll>> pq;
        pq.push({0,x});
        ll cur=0;
        ll tlp=0;
        int total=0;
        while(pq.size()>0)
        {
            pll it=pq.top();
            pq.pop();
            int u=it.second;
            ll c=it.first;
            if((cur+c)>k)
                break;
            vis[u]=1;
            cur+=c;
            paid[u]+=c;
            total++;
            for(auto [w,v]:ma[u])
            {
                if(!vis[v])
                {
                    pq.push({c+w,v});
                    vis[v]=1;
                }
            }
        }
        mx=max(mx,total);
    }
    {
        for(int i=0;i<=n;i++)vis[i]=0;
        priority_queue<pll,vpl,greater<pll>> pq;
        pq.push({0,y});
        ll cur=0;
        ll tlp=0;
        int total=0;
        while(pq.size()>0)
        {
            pll it=pq.top();
            pq.pop();
            int u=it.second;
            ll c=it.first;
            if((cur+c)>k)
                break;
            vis[u]=1;
            cur+=c;
            paid[u]+=c;
            total++;
            for(auto [w,v]:ma[u])
            {
                if(!vis[v])
                {
                    pq.push({c+w,v});
                    vis[v]=1;
                }
            }
        }
        mx=max(mx,total);
    }
    return mx;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:29:12: warning: unused variable 'tlp' [-Wunused-variable]
   29 |         ll tlp=0;
      |            ^~~
closing.cpp:59:12: warning: unused variable 'tlp' [-Wunused-variable]
   59 |         ll tlp=0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 21844 KB 1st lines differ - on the 1st token, expected: '451', found: '319'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 6492 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -