# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
655007 | 2022-11-02T12:21:18 Z | DJeniUp | Designated Cities (JOI19_designated_cities) | C++17 | 13 ms | 19480 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[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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 9684 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Runtime error | 13 ms | 19480 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 9684 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 9684 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 9684 KB | Output is correct |
2 | Runtime error | 13 ms | 19480 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 9684 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |