Submission #376130

# Submission time Handle Problem Language Result Execution time Memory
376130 2021-03-11T01:17:20 Z daniel920712 Designated Cities (JOI19_designated_cities) C++14
7 / 100
634 ms 81516 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>

using namespace std;
vector < pair < long long , long long > > Next[200005];
map < long long , long long > all[200005];
long long ans[200005];
void F(long long here,long long fa)
{
    for(auto i:Next[here])
    {
        if(i.first!=fa)
        {
            ans[1]+=i.second;
            F(i.first,here);
        }
    }
}
void F2(long long here,long long fa)
{
    for(auto i:Next[here])
    {
        if(i.first!=fa)
        {
            ans[i.first]=ans[here]-all[here][i.first]+all[i.first][here];
            F2(i.first,here);
        }
    }
}
int main()
{
    long long N,i,a,b,c,d,how=1e18;
    scanf("%lld",&N);
    for(i=1;i<N;i++)
    {
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
        Next[a].push_back(make_pair(b,c));
        Next[b].push_back(make_pair(a,d));
        all[a][b]=c;
        all[b][a]=d;
    }
    F(1,-1);
    F2(1,-1);
    for(i=1;i<=N;i++)
    {
        how=min(how,ans[i]);
    }
    printf("%lld\n",how);
    return 0;
}

Compilation message

designated_cities.cpp: In function 'int main()':
designated_cities.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |     scanf("%lld",&N);
      |     ~~~~~^~~~~~~~~~~
designated_cities.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |         scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 14444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 466 ms 57836 KB Output is correct
3 Correct 511 ms 80620 KB Output is correct
4 Correct 460 ms 56300 KB Output is correct
5 Correct 502 ms 57824 KB Output is correct
6 Correct 479 ms 61036 KB Output is correct
7 Correct 581 ms 57308 KB Output is correct
8 Correct 502 ms 81516 KB Output is correct
9 Correct 634 ms 56916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 14572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 14444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14444 KB Output is correct
2 Correct 466 ms 57836 KB Output is correct
3 Correct 511 ms 80620 KB Output is correct
4 Correct 460 ms 56300 KB Output is correct
5 Correct 502 ms 57824 KB Output is correct
6 Correct 479 ms 61036 KB Output is correct
7 Correct 581 ms 57308 KB Output is correct
8 Correct 502 ms 81516 KB Output is correct
9 Correct 634 ms 56916 KB Output is correct
10 Incorrect 10 ms 14572 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 14444 KB Output isn't correct
2 Halted 0 ms 0 KB -