Submission #1021134

#TimeUsernameProblemLanguageResultExecution timeMemory
1021134Nika533Designated Cities (JOI19_designated_cities)C++14
7 / 100
148 ms32580 KiB
#pragma gcc diagnostic "-std=c++1z" #include <bits/stdc++.h> #define int long long #define pb push_back #define f first #define s second #define MOD 1000000007 #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(),(x).rend() using namespace std; const int N=2e5+5; int n,m,T,k,q,tot,ans=1e18; vector<pair<int,pii>> g[N]; void dfs0(int x, int p) { // cout<<"X "<<x<<" "<<p<<endl; for (auto A:g[x]) { int y=A.f,w1=A.s.f,w2=A.s.s; if (y==p) continue; tot-=w2; dfs0(y,x); } } void dfs(int x, int p) { ans=min(ans,tot); for (auto A:g[x]) { int y=A.f,w1=A.s.f,w2=A.s.s; if (y==p) continue; tot-=w1-w2; dfs(y,x); tot+=w1-w2; } } void test_case() { cin>>n; for (int i=1; i<=n-1; i++) { int a,b,c,d; cin>>a>>b>>c>>d; g[a].pb({b,{c,d}}); g[b].pb({a,{d,c}}); tot+=c+d; } cin>>q; int query[q+1]; for (int i=1; i<=q; i++) cin>>query[i]; dfs0(1,0); dfs(1,1); cout<<ans<<endl; } main () { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; while (T--) test_case(); }

Compilation message (stderr)

designated_cities.cpp:1: warning: ignoring '#pragma gcc diagnostic' [-Wunknown-pragmas]
    1 | #pragma gcc diagnostic "-std=c++1z"
      | 
designated_cities.cpp: In function 'void dfs0(long long int, long long int)':
designated_cities.cpp:20:21: warning: unused variable 'w1' [-Wunused-variable]
   20 |           int y=A.f,w1=A.s.f,w2=A.s.s;
      |                     ^~
designated_cities.cpp: At global scope:
designated_cities.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...