版本比较
10.18测试总结
正文
增加 9 行删除 9 行
13 行未改动14151617181920212237 行未改动606162636465666768230 行未改动全部展开29930030130230330430530630730830931031131231331431531631713 行未改动33133233333433533633733833916 行未改动3563573583593603613623633643653663673684 行未改动3733743753763773783793803814 行未改动13 行未改动每个测试点包含多组测试数据。输入的第一行,包含一个整数 $T$,表示测试数据的组数。对于每组测试数据:第一行,包含一个正整数 $n$。第二行,包含 $2 n$ 个用空格隔开的整数 $a_1, a_2, \ldots, a_{2 n}$。## 输出格式37 行未改动bool check(string s) {int len = s.size(); bool ff = 1;for (int i = 0, j = len - 1; i <= j; i++, j--) if (s[i] != s[j]) {ff = false; break;}if (ff) return true;else return false;}void dfs(int u, string ans, string s, int l, int r) {if (f) return;if (u == 2 * n + 1 && s != "" && check(s)) {230 行未改动全部展开#define ll long long#define endl '\n'const int N = 2500 + 10;ll n, m, k, a[N], ans;vector<int> g[N];bool vis[N];void dfs(int u, int step, ll sum) {if (step > 5) return;for (int i = 0; i < g[u].size(); i++) {int v = g[u][i];if (v == 1 && step + 1 == 5) ans = max(ans, sum);if (vis[v]) continue;vis[v] = 1;dfs(v, step + 1, sum + a[v]);vis[v] = 0;}}int main() {ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);13 行未改动## 正确代码(正解)```cpp#include <bits/stdc++.h>using namespace std;#define int long longconst int MAXN = 3007;vector<int> g[MAXN], f[MAXN];int n, m, k, w[MAXN], dis[MAXN];16 行未改动if (f[x].size() > 3) f[x].pop_back();}}if (dis[u] == k + 1) continue;for (int v : g[u])if (dis[v] == -1) {dis[v] = dis[u] + 1;q.push(v);}}}signed main() {cin >> n >> m >> k;4 行未改动}for (int i = 1; i <= n; i++) bfs(i);int ans = 0;for (int b = 1; b <= n; b++)for (int c = 1; c <= n; c++)if (vis[b][c])for (int a : f[b])for (int d : f[c])if (a != c && b != d && a != d) ans = max(ans, w[a] + w[b] + w[c] + w[d]);4 行未改动13 行未改动14151617181920212237 行未改动606162636465666768230 行未改动全部展开29930030130230330430530630730830931031131231331431531631713 行未改动33133233333433533633733833916 行未改动3563573583593603613623633643653663673684 行未改动3733743753763773783793803814 行未改动13 行未改动每个测试点包含多组测试数据。输入的第一行,包含一个整数 $T$,表示测试数据的组数。对于每组测试数据:第一行,包含一个正整数 $n$。第二行,包含 $2 n$ 个用空格隔开的整数 $a_1, a_2, \ldots, a_{2 n}$。## 输出格式37 行未改动bool check(string s) {int len = s.size(); bool ff = 1;for (int i = 0, j = len - 1; i <= j; i++, j--) if (s[i] != s[j]) {ff = false; break;}if (ff) return true;else return false;}void dfs(int u, string ans, string s, int l, int r) {if (f) return;if (u == 2 * n + 1 && s != "" && check(s)) {230 行未改动全部展开#define ll long long#define endl '\n'const int N = 2500 + 10;ll n, m, k, a[N], ans;vector<int> g[N];bool vis[N];void dfs(int u, int step, ll sum) {if (step > 5) return;for (int i = 0; i < g[u].size(); i++) {int v = g[u][i];if (v == 1 && step + 1 == 5) ans = max(ans, sum);if (vis[v]) continue;vis[v] = 1;dfs(v, step + 1, sum + a[v]);vis[v] = 0;}}int main() {ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);13 行未改动## 正确代码(正解)```cpp#include <bits/stdc++.h>using namespace std;#define int long longconst int MAXN = 3007;vector<int> g[MAXN], f[MAXN];int n, m, k, w[MAXN], dis[MAXN];16 行未改动if (f[x].size() > 3) f[x].pop_back();}}if (dis[u] == k + 1) continue;for (int v : g[u])if (dis[v] == -1) {dis[v] = dis[u] + 1;q.push(v);}}}signed main() {cin >> n >> m >> k;4 行未改动}for (int i = 1; i <= n; i++) bfs(i);int ans = 0;for (int b = 1; b <= n; b++)for (int c = 1; c <= n; c++)if (vis[b][c])for (int a : f[b])for (int d : f[c])if (a != c && b != d && a != d) ans = max(ans, w[a] + w[b] + w[c] + w[d]);4 行未改动