Submission #311457

# Submission time Handle Problem Language Result Execution time Memory
311457 2020-10-10T09:40:17 Z mosiashvililuka Training (IOI07_training) C++17
30 / 100
3 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,st,f[1009],g[1009],dp[1009],jm,ka;
vector <int> v[1009];
vector <pair <int, int> > vv[1009];
void dfs(int q, int w){
    zx++;
    f[q]=zx;
    g[zx]=q;
    for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
        if((*it)==w) continue;
        dfs((*it),q);
    }
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(i=1; i<=b; i++){
        cin>>c>>d>>e;
        jm+=e;
        if(e==0){
            v[c].push_back(d);
            v[d].push_back(c);
        }else{
            vv[c].push_back(make_pair(d,e));
            vv[d].push_back(make_pair(c,e));
        }
    }
    for(i=1; i<=a; i++){
        if(v[i].size()==1) break;
    }
    st=i;
    zx=0;
    dfs(st,0);
    for(i=1; i<=a; i++){
        dp[i]=dp[i-1];
        for(vector <pair <int, int> >::iterator it=vv[g[i]].begin(); it!=vv[g[i]].end(); it++){
            if(f[(*it).first]>i) continue;
            d=f[(*it).first];c=i;
            if(abs(c-d)%2==1){
                continue;
            }
            if(dp[c]<dp[d]+(*it).second){
                dp[c]=dp[d]+(*it).second;
            }
        }
    }
    cout<<jm-dp[a];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -