답안 #66372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66372 2018-08-10T10:39:04 Z mirbek01 Shortcut (IOI16_shortcut) C++17
0 / 100
3 ms 380 KB
# include "shortcut.h"
# include <bits/stdc++.h>

using namespace std;

const int N = 1e3 + 2;

int vr, n;
long long sum, d[N];
vector < pair <int, int> > g[N];
vector <int> vec;

void dfs(int v){
      for(int i = 0; i < n; i ++)
            d[i] = 1e18;
      d[v] = 0;
      set < pair <long long, int> > st;
      st.insert({0, v});
      while(!st.empty()){
            int vv = st.begin()->second;
            st.erase(st.begin());
            for(auto to : g[vv]){
                  if(d[vv] + to.second < d[to.first]){
                        st.erase({to.first, d[to.first]});
                        d[to.first] = d[vv] + to.second;
                        st.insert({d[to.first], to.first});
                  }
            }
      }
      sum = 0;
      for(int i = 0; i < n; i ++){
            long long cur = vec[v] + d[i];
            if(i != v) cur += vec[i];
            if(sum < cur){
                  sum = cur;
                  vr = i;
            }
      }
}

long long find_shortcut(int NN, vector<int> l, vector<int> d, int c){
      n = NN;
      long long ans = 1e18;
      for(int i = 0; i < n - 1; i ++){
            g[i].push_back({i + 1, l[i]});
            g[i + 1].push_back({i, l[i]});
      }
      vec = d;
      for(int i = 0; i < n; i ++){
            for(int j = i + 1; j < n; j ++){
                  g[i].push_back({j, c});
                  g[j].push_back({i, c});
                  dfs(0);
                  dfs(vr);
                  ans = min(ans, sum);
                  g[i].pop_back();
                  g[j].pop_back();
            }
      }
      return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Incorrect 2 ms 380 KB n = 9, incorrect answer: jury 110 vs contestant 100
3 Halted 0 ms 0 KB -