版本比较
9.27双指针进阶总结
正文
增加 7 行删除 7 行
229 行未改动全部展开230231232233234234235236237238113 行未改动全部展开35235335435535635635735835935936036136236236336436536612 行未改动379380381382383383384385386385386387388389390229 行未改动全部展开 while (tot > b) {tot -= a[i]; i++;} } cout << ans; return 0;} }```
# P1638 逛画展
113 行未改动全部展开
## 正确代码```cpp#include <bits/stdc++.h>#define int long long #define int long long#define endl '\n'using namespace std;int n, m, ans1, ans2 = 1e9, tot; int n, m, ans1, ans2 = 1e9, tot;string a[1007], b[100007];map<string, bool> vis;map<string, int> cnt, dis; map<string, int> cnt, dis;int i = 1, j = 0;signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);12 行未改动 } while (tot == ans1) { if (ans2 > j - i + 1) ans2 = j - i + 1; cnt[b[i]]--; if (cnt[b[i]] == 0 && vis[b[i]]) tot--; if (cnt[b[i]] == 0 && vis[b[i]]) tot--; i++; } } } } cout << ans1 << endl << ans2 << endl; return 0;}```