답안 #864111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864111 2023-10-22T04:03:00 Z Ice_man Truck Driver (IOI23_deliveries) C++17
0 / 100
74 ms 11284 KB
#include "deliveries.h"
#include <iostream>
#include <vector>


#define maxn 100005
#define maxq 300005
#define INF 1000000010
#define endl '\n'

using namespace std;

long long n;

long long t[maxn];
long long c[maxn];

vector <pair <int , int> > v[maxn];
long long ans;

long long pom;

void dfs(long long node , long long parent = -1)
{
    c[node] = t[node];

    for(long long i = 0; i < (long long)v[node].size(); i++)
    {
        if(v[node][i].first == parent) continue;
        dfs(v[node][i].first , node);

        ans += v[node][i].second * min(c[v[node][i].first] , pom - c[v[node][i].first]) * 2;
        c[node] += c[v[node][i].first];
    }

}

void init(int N, vector<int> U, vector<int> V, vector<int> T, vector<int> W)
{
    pom = 1;
    n = N;
    ///cout << pom << endl;
    for(long long i = 0; i < (long long)U.size(); i++) v[U[i]].push_back({V[i] , W[i]});
    for(long long i = 0; i < (long long)V.size(); i++) v[V[i]].push_back({U[i] , W[i]});



    for(long long i = 0; i < T.size(); i++) pom += T[i];

    ///cout << pom << endl;

    for(long long i = 0; i < T.size(); i++) t[i] = T[i];
}



long long max_time(int S , int X)
{
    pom -= t[S];
    pom += X;
    t[S] = X;

    ans = 0;

    dfs(0 , -1);
    return ans;

}

/**int main()
{
    init(5, {0, 0, 1, 1}, {1, 2, 3, 4}, {1, 2, 3, 1}, {0, 0, 1, 0, 1});
    cout << max_time(0 , 1) << endl;


    return 0;
}*/

Compilation message

deliveries.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
deliveries.cpp:48:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(long long i = 0; i < T.size(); i++) pom += T[i];
      |                          ~~^~~~~~~~~~
deliveries.cpp:52:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(long long i = 0; i < T.size(); i++) t[i] = T[i];
      |                          ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 11284 KB 3rd lines differ - on the 1st token, expected: '39049160', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2648 KB 3rd lines differ - on the 1st token, expected: '1627540', found: '938038'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 11284 KB 3rd lines differ - on the 1st token, expected: '39049160', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 11284 KB 3rd lines differ - on the 1st token, expected: '39049160', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 11284 KB 3rd lines differ - on the 1st token, expected: '39049160', found: '0'
2 Halted 0 ms 0 KB -