版本比较
题解:P1526 [NOI2003] 智破连环阵
正文
增加 14 行删除 14 行
23 行未改动24252627282930313233343536378 行未改动4647484950515253545556575859606162636465666768697020 行未改动9192939495969798991001011021031048 行未改动113114115116117118119120121122123124125126127128129130131132133134135136137130 行未改动全部展开23 行未改动return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);}void dfs(int current_weapon, int bombs_used, vector<bool>& bomb_used) {if (current_weapon > M) {min_bombs = min(min_bombs, bombs_used);return;}for (int i = 0; i < n; ++i) {if (!bomb_used[i] && distanceSq(weapons[current_weapon-1], bombs[i]) <= k*k) {bomb_used[i] = true;int destroyed = current_weapon;8 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);cin >> M >> n >> k;weapons.resize(M);bombs.resize(n);used.resize(n, false);for (int i = 0; i < M; ++i) {cin >> weapons[i].x >> weapons[i].y;}for (int i = 0; i < n; ++i) {cin >> bombs[i].x >> bombs[i].y;}vector<bool> bomb_used(n, false);dfs(1, 0, bomb_used);cout << min_bombs << endl;return 0;}```20 行未改动}void dfs(int current_weapon, int bombs_used, vector<bool>& bomb_used) {if (bombs_used >= min_bombs) return; // 剪枝if (current_weapon > M) {min_bombs = min(min_bombs, bombs_used);return;}for (int i = 0; i < n; ++i) {if (!bomb_used[i] && distanceSq(weapons[current_weapon-1], bombs[i]) <= k*k) {bomb_used[i] = true;int destroyed = current_weapon;8 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);cin >> M >> n >> k;weapons.resize(M);bombs.resize(n);used.resize(n, false);for (int i = 0; i < M; ++i) {cin >> weapons[i].x >> weapons[i].y;}for (int i = 0; i < n; ++i) {cin >> bombs[i].x >> bombs[i].y;}vector<bool> bomb_used(n, false);dfs(1, 0, bomb_used);cout << min_bombs << endl;return 0;}```130 行未改动全部展开23 行未改动24252627282930313233343536378 行未改动4647484950515253545556575859606162636465666768697020 行未改动9192939495969798991001011021031048 行未改动113114115116117118119120121122123124125126127128129130131132133134135136137130 行未改动全部展开23 行未改动return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);}void dfs(int current_weapon, int bombs_used, vector<bool>& bomb_used) {if (current_weapon > M) {min_bombs = min(min_bombs, bombs_used);return;}for (int i = 0; i < n; ++i) {if (!bomb_used[i] && distanceSq(weapons[current_weapon-1], bombs[i]) <= k*k) {bomb_used[i] = true;int destroyed = current_weapon;8 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);cin >> M >> n >> k;weapons.resize(M);bombs.resize(n);used.resize(n, false);for (int i = 0; i < M; ++i) {cin >> weapons[i].x >> weapons[i].y;}for (int i = 0; i < n; ++i) {cin >> bombs[i].x >> bombs[i].y;}vector<bool> bomb_used(n, false);dfs(1, 0, bomb_used);cout << min_bombs << endl;return 0;}```20 行未改动}void dfs(int current_weapon, int bombs_used, vector<bool>& bomb_used) {if (bombs_used >= min_bombs) return; // 剪枝if (current_weapon > M) {min_bombs = min(min_bombs, bombs_used);return;}for (int i = 0; i < n; ++i) {if (!bomb_used[i] && distanceSq(weapons[current_weapon-1], bombs[i]) <= k*k) {bomb_used[i] = true;int destroyed = current_weapon;8 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);cin >> M >> n >> k;weapons.resize(M);bombs.resize(n);used.resize(n, false);for (int i = 0; i < M; ++i) {cin >> weapons[i].x >> weapons[i].y;}for (int i = 0; i < n; ++i) {cin >> bombs[i].x >> bombs[i].y;}vector<bool> bomb_used(n, false);dfs(1, 0, bomb_used);cout << min_bombs << endl;return 0;}```130 行未改动全部展开