Submission #842295

# Submission time Handle Problem Language Result Execution time Memory
842295 2023-09-02T17:42:12 Z flashmt Closing Time (IOI23_closing) C++17
8 / 100
105 ms 25716 KB
#include "closing.h"
// #include "Debug.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;

int n;
vector<pair<int, int>> a[N];

vector<long long> bfs(int s)
{
  vector<long long> dist(n, -1);
  queue<int> q;
  dist[s] = 0;
  q.push(s);
  while (!empty(q))
  {
    int x = q.front();
    q.pop();
    for (auto [y, w] : a[x])
      if (dist[y] < 0)
      {
        dist[y] = dist[x] + w;
        q.push(y);
      }
  }
  return dist;
}

int max_score(int N, int A, int B, long long budget, vector<int> U, vector<int> V, vector<int> W)
{
  n = N;
  for (int i = 0; i < n; i++)
    a[i].clear();
  for (int i = 0; i < size(U); i++)
  {
    a[U[i]].push_back({V[i], W[i]});
    a[V[i]].push_back({U[i], W[i]});
  }

  auto distA = bfs(A);
  auto distB = bfs(B);

  if (distA[B] > budget * 2)
  {
    vector<long long> allDists = distA;
    for (auto d : distB)
      allDists.push_back(d);
    sort(begin(allDists), end(allDists));
    int ans = 0;
    for (auto d : allDists)
      if (d <= budget)
      {
        ans++;
        budget -= d;
      }
    return ans;
  }

  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:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for (int i = 0; i < size(U); i++)
      |                   ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 24644 KB Output is correct
2 Correct 105 ms 25716 KB Output is correct
3 Correct 66 ms 9044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -