版本比较
回忆
正文
增加 24 行删除 24 行
14 行未改动15161718191920212223242526272828293031323233343435363738393839404142437 行未改动5152535455555657585959606162636465646566676867686970717172737475757677787919 行未改动991001011021031031041051061074 行未改动112113114115116116117118119120121122123124124125126127127128129130131132133134134135136137138138139140141142142143144145146146147148149150151151152153154155156157158159160160161162163164168 行未改动全部展开14 行未改动 } return res;}
// 计算长度为 w、1 的个数 ≤k 的码字总数 // 计算长度为 w、1 的个数 ≤k 的码字总数long long count_patterns(int w, int k) { long long total = 0; for (int t = 0; t <= min(w, k); ++t) { total += comb(w, t); } return total;}
// 抽象测试接口 // 抽象测试接口int test_subset(const vector<vector<int>>& plan);
int solve(int n, int k) { // === 第 1 步:求最小 w === // === 第 1 步:求最小 w === int w = 1; while ( ① ) { while ( ① ) { ++w; } cout << w << endl; // === 第 2 步:生成测试方案 ===
// === 第 2 步:生成测试方案 === vector<vector<int>> code(n, vector<int>(w, 0)); int idx = 0; for (int ones = 0; ones <= k && idx < n; ++ones) { vector<int> bits(w, 0);7 行未改动 break; } } while ( std:: ② ); }
vector<vector<int>> plan(w); for (int i = 0; i < w; ++i) { for (int j = 0; j < n; ++j) { if ( ③ ) { if ( ③ ) { plan[i].push_back(j); } } } // === 第 3 步:调用测试接口 ===
// === 第 3 步:调用测试接口 === int signature = test_subset(plan); // === 第 4 步:结果解码 ===
// === 第 4 步:结果解码 === vector<int> sig_bits(w, 0); for (int i = 0; i < w; ++i) { if ( ④ ) { if ( ④ ) { sig_bits[i] = 1; } }
for (int j = 0; j < n; ++j) { if ( ⑤ ) return j; }}19 行未改动struct Edge { int to; int weight;};
struct State { long long dist; int u; int used_freebie;//0 for not used, 1 for used4 行未改动
int main() { int n, m, s, t; cin >> n >> m >> s >> t;
vector<vector<Edge>> adj(n + 1); for (int i = 0; i < m; ++i) { int u, v, w; cin >> u >> v >> w; adj[u].push_back({v, w}); adj[v].push_back({u, w}); }
vector<vector<long long>> d(n + 1, vector<long long>(2, INF)); priority_queue<State, vector<State>, greater<State>> pq;
d[s][0]= 0; pq.push({0, s, ① });
while(!pq.empty()) { State current =pq.top(); pq.pop();
long long dist = current.dist; int u= current.u; int used = current.used_freebie;
if(dist > ② ){ continue; }
for (const auto &edge : adj[u]) { int v = edge.to; int w = edge.weight;
if(d[u][used] + w < ③ ){ ③ = d[u][used] + w; pq.push({ ③ , v , used}); }
if(used == 0){ if( ④ < d[v][1]){ d[v][1] = ④ ; pq.push({d[v][1], v, 1}); } } } }
cout << ⑤ << endl; return 0;}
168 行未改动全部展开