Submission #1059600

# Submission time Handle Problem Language Result Execution time Memory
1059600 2024-08-15T05:59:32 Z mychecksedad Closing Time (IOI23_closing) C++17
8 / 100
131 ms 48576 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long
#define ff first
#define ss second
const int N = 200005;

vector<pair<int, ll>> g[N];
void dfs(int v, int p, vector<ll> &D){
  for(auto U: g[v]){
    int u = U.ff;
    if(u != p){
      D[u] = D[v] + U.ss;
      dfs(u, v, D);
    }
  }
}
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) g[i].clear();
  for(int i = 0; i < n - 1; ++i){
    g[V[i]].pb({U[i], W[i]});
    g[U[i]].pb({V[i], W[i]});
  }
  vector<ll> D1(n), D2(n);
  dfs(X, X, D1);
  dfs(Y, Y, D2);
  vector<array<ll, 3>> A;
  K *= 2;
  for(int i = 0; i < n; ++i){
    A.pb({min(D1[i], D2[i]) * 2, i, 1});
    A.pb({max(D1[i], D2[i]), i, 2});
  }
  int ans = 0;
  vector<int> used(n);
  sort(all(A));
  for(int i = 0; i < A.size(); ++i){
    int v = A[i][1];
    if(used[v] == 2){
       continue;
    }
    if(used[v] == 1){
      if(K >= A[i][0] - min(D1[v], D2[v])){
        K -= A[i][0] - min(D1[v], D2[v]);
        used[v] = 2;
        ++ans;
      }
    }else{
      if(K >= A[i][0]){
        K -= A[i][0];
        ans += A[i][2];
        used[v] = A[i][1];
      }
    }
  }

  return ans;
}

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:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int i = 0; i < A.size(); ++i){
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 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 Correct 126 ms 43428 KB Output is correct
2 Correct 131 ms 48576 KB Output is correct
3 Correct 66 ms 10412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
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: '7'
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: '7'
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: '7'
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: '7'
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: '7'
2 Halted 0 ms 0 KB -