Submission #969284

# Submission time Handle Problem Language Result Execution time Memory
969284 2024-04-24T21:37:21 Z angels Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 21336 KB
#include "closing.h"

#include <bits/stdc++.h>
using namespace std;

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    int n=N, x=X, y=Y;
    long long k=K;
    vector<pair<int, int>>a[n];
    for(int i=0; i<n-1; i++)
    {
        a[U[i]].push_back({V[i], W[i]});
        a[V[i]].push_back({U[i], W[i]});
    }
    int rez=0;
    int visited[n];
    memset(visited, 0, sizeof(visited));
    int id=1;
    for(int i=0; i<n; i++)
    {
        queue<pair<int, long long>>q;
        q.push(make_pair(i, 0));
        while(!q.empty())
        {
            pair<int, long long>ww=q.front();
            q.pop();
            visited[ww.first]=id;
            if((ww.first==x || ww.first==y) && ww.second<=k)
            {
                rez++;
                break;
            }
            if(ww.second>k)
                continue;
            for(int i=0; i<a[ww.first].size(); i++)
            {
                if(visited[a[ww.first][i].first]!=id)
                {
                    q.push(make_pair(a[ww.first][i].first, ww.second+a[ww.first][i].second));
                }
            }
        }
        id++;
    }
    return rez;
    return 0;
}

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:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int i=0; i<a[ww.first].size(); i++)
      |                          ~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 21336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -