Submission #655008

# Submission time Handle Problem Language Result Execution time Memory
655008 2022-11-02T12:22:18 Z DJeniUp Designated Cities (JOI19_designated_cities) C++17
7 / 100
568 ms 71860 KB
#include "bits/stdc++.h"
//#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef long double ld;

#define fr first
#define sc second
#define pb push_back
#define INF 100000000000000007
#define I 100000000000007
#define N 100007
#define endl '\n'
#define MOD 998244353

ll n,res,resx;

vector<pairll>v[2*N];

map<ll,ll>m[2*N];

ll S(ll x,ll y){
    ll rs=0;
    for(int i=0;i<v[x].size();i++){
        if(v[x][i].fr!=y){
            rs+=v[x][i].sc+S(v[x][i].fr,x);
        }
    }
    return rs;
}

void D(ll x,ll y,ll z){
    if(res>z){
        res=z;
        resx=x;
    }
    for(int i=0;i<v[x].size();i++){
        if(v[x][i].fr!=y){
            D(v[x][i].fr,x,z-v[x][i].sc+m[v[x][i].fr][x]);
        }
    }
    return ;
}

int main()
{
    cin>>n;
    for(int i=1;i<n;i++){
        ll x,y,z,z1;
        cin>>x>>y>>z>>z1;
        v[x].pb({y,z});
        v[y].pb({x,z1});
        m[x][y]=z;
        m[y][x]=z1;
    }
    res=INF;
    D(1,1,S(1,1));
    cout<<res<<endl;

    return 0;
}

Compilation message

designated_cities.cpp: In function 'll S(ll, ll)':
designated_cities.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
designated_cities.cpp: In function 'void D(ll, ll, ll)':
designated_cities.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14376 KB Output is correct
2 Correct 525 ms 55916 KB Output is correct
3 Correct 568 ms 71360 KB Output is correct
4 Correct 494 ms 54588 KB Output is correct
5 Correct 527 ms 56076 KB Output is correct
6 Correct 564 ms 58468 KB Output is correct
7 Correct 539 ms 55432 KB Output is correct
8 Correct 561 ms 71860 KB Output is correct
9 Correct 565 ms 55324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 14344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 14376 KB Output is correct
2 Correct 525 ms 55916 KB Output is correct
3 Correct 568 ms 71360 KB Output is correct
4 Correct 494 ms 54588 KB Output is correct
5 Correct 527 ms 56076 KB Output is correct
6 Correct 564 ms 58468 KB Output is correct
7 Correct 539 ms 55432 KB Output is correct
8 Correct 561 ms 71860 KB Output is correct
9 Correct 565 ms 55324 KB Output is correct
10 Incorrect 7 ms 14344 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -