Submission #1000905

# Submission time Handle Problem Language Result Execution time Memory
1000905 2024-06-18T11:04:39 Z 변재우(#10901) Closing Time (IOI23_closing) C++17
8 / 100
100 ms 38440 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const int Nmax=200010;
vector<pair<int, ll>> adj[Nmax];
vector<ll> P;

void DFS(int curr, int prev, ll dist) {
    P.push_back(dist);
    for(auto [next, w]:adj[curr]) if(next!=prev) DFS(next, curr, dist+w);
}

int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    int ans=0; ll sum=0;
    X++, Y++;
    for(int i=1; i<=N; i++) adj[i].clear(); P.clear();
    for(int i=0; i<N-1; i++) adj[U[i]+1].push_back({V[i]+1, W[i]}), adj[V[i]+1].push_back({U[i]+1, W[i]});
    DFS(X, 0, 0), DFS(Y, 0, 0);
    sort(P.begin(), P.end());
    for(int i=0; i<P.size(); i++) if(sum+P[i]<=K) ans++, sum+=P[i];
    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for(int i=1; i<=N; i++) adj[i].clear(); P.clear();
      |     ^~~
closing.cpp:18:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   18 |     for(int i=1; i<=N; i++) adj[i].clear(); P.clear();
      |                                             ^
closing.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0; i<P.size(); i++) if(sum+P[i]<=K) ans++, sum+=P[i];
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 90 ms 29892 KB Output is correct
2 Correct 100 ms 38440 KB Output is correct
3 Correct 49 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
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: '6', found: '5'
2 Halted 0 ms 0 KB -