正文
增加 27 行删除 27 行
123456737 行未改动45464748495051525354555657585960616263646566676869707172737475767778798081828384858643 行未改动13013113213313413513613713813914014114214314414514614714814915015115215315415515615715815950 行未改动2102112122132142152162172182192202212223 行未改动2262272282292302312322332342352362372382392402412422432442452462474 行未改动25225325425525625725825926034 行未改动295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332# 比赛情况**比赛传送门:[![这是头图链接,但不见了]()](https://www.luogu.com.cn/contest/320395#problems)****比赛内容:** 综合| 题号 | 分数 |37 行未改动int main(){int n;cin >> n;for(int i = 1;i <= n;i++){string s;double x;cin >> s >> x;if(mp.count(s)){mp[s] += x;} else{mp.insert({s,x * 0.75});}}for(pair<string,double> p : mp){ // 范围循环必须开启 C++11cout << p.first;printf(" %.1lf\n",p.second);}return 0;}```## T2 - 位运算进阶### 错因花 $30$ 分钟发现一个非正解规律(答案为 $a_l \oplus a_r$),居然得了 $84$ 分!### 题意**题意概括**:给定一个长度为 $n$ 的非负整数序列,有 $q$ 次操作。操作分两种:1. **修改**:将第 $i$ 个位置的值改为 $j$;2. **查询**:给定区间 $[l,r]$,求该区间内所有**子区间**的异或和的异或和。输出所有查询操作的答案。43 行未改动int main(){int n,q;cin >> n >> q;for(int i = 1;i <= n;i++){cin >> a[i];}while(q--){int op,x,y;cin >> op >> x >> y;if(op == 1){a[x] = y;} else{int& l = x,r = y;int ans = 0;for(int i = l;i <= r;i++){int tmp = (i - l + 1) * (r - i + 1);if(tmp % 2 == 1){ans ^= a[i];}}cout << ans << "\n";}}50 行未改动signed main(){int n,ans = 0;cin >> n;for(int i = 1;i <= n;i++){int t,k;cin >> t >> k;while(q.size() != 0){Node num = q.front();if(num.t + 86400 <= t){mp[num.x]--;3 行未改动q.pop();}else break;}for(int j = 1;j <= k;j++){int x;cin >> x;mp[x]++;q.push({t,x});if(mp[x] == 1){ans++;}}cout << ans << endl;}return 0;}```4 行未改动用了 `set` 排序,忘了会自动去重,应该用 `multiset`。### 题意给定一个长度为 $N$ 的非负整数序列 $A$。对于每个 **奇数长度** 的前缀(即前 $1, 3, 5, \dots$ 个元素),将该前缀中的数从小到大排序,输出排在正中间的那个数(中位数)。按顺序输出这些中位数,共 $\lfloor \frac{N+1}{2} \rfloor$ 行。34 行未改动signed main(){int n;cin >> n;for(int i = 1;i <= n;i++){int t;cin >> t;if(!q1.size()){q1.push(t);} else{if(q1.top() >= t){q1.push(t);} else{q2.push(t);}}if(i % 2 == 0) continue;while(q1.size() > i / 2 + 1){q2.push(q1.top());q1.pop();}while(q1.size() < i / 2 + 1){q1.push(q2.top());q2.pop();}cout << q1.top() << "\n";}return 0;}```## 感谢观看!123456737 行未改动45464748495051525354555657585960616263646566676869707172737475767778798081828384858643 行未改动13013113213313413513613713813914014114214314414514614714814915015115215315415515615715815950 行未改动2102112122132142152162172182192202212223 行未改动2262272282292302312322332342352362372382392402412422432442452462474 行未改动25225325425525625725825926034 行未改动295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332# 比赛情况**比赛传送门:[![这是头图链接,但不见了]()](https://www.luogu.com.cn/contest/320395#problems)****比赛内容:** 综合| 题号 | 分数 |37 行未改动int main(){int n;cin >> n;for(int i = 1;i <= n;i++){string s;double x;cin >> s >> x;if(mp.count(s)){mp[s] += x;} else{mp.insert({s,x * 0.75});}}for(pair<string,double> p : mp){ // 范围循环必须开启 C++11cout << p.first;printf(" %.1lf\n",p.second);}return 0;}```## T2 - 位运算进阶### 错因花 $30$ 分钟发现一个非正解规律(答案为 $a_l \oplus a_r$),居然得了 $84$ 分!### 题意**题意概括**:给定一个长度为 $n$ 的非负整数序列,有 $q$ 次操作。操作分两种:1. **修改**:将第 $i$ 个位置的值改为 $j$;2. **查询**:给定区间 $[l,r]$,求该区间内所有**子区间**的异或和的异或和。输出所有查询操作的答案。43 行未改动int main(){int n,q;cin >> n >> q;for(int i = 1;i <= n;i++){cin >> a[i];}while(q--){int op,x,y;cin >> op >> x >> y;if(op == 1){a[x] = y;} else{int& l = x,r = y;int ans = 0;for(int i = l;i <= r;i++){int tmp = (i - l + 1) * (r - i + 1);if(tmp % 2 == 1){ans ^= a[i];}}cout << ans << "\n";}}50 行未改动signed main(){int n,ans = 0;cin >> n;for(int i = 1;i <= n;i++){int t,k;cin >> t >> k;while(q.size() != 0){Node num = q.front();if(num.t + 86400 <= t){mp[num.x]--;3 行未改动q.pop();}else break;}for(int j = 1;j <= k;j++){int x;cin >> x;mp[x]++;q.push({t,x});if(mp[x] == 1){ans++;}}cout << ans << endl;}return 0;}```4 行未改动用了 `set` 排序,忘了会自动去重,应该用 `multiset`。### 题意给定一个长度为 $N$ 的非负整数序列 $A$。对于每个 **奇数长度** 的前缀(即前 $1, 3, 5, \dots$ 个元素),将该前缀中的数从小到大排序,输出排在正中间的那个数(中位数)。按顺序输出这些中位数,共 $\lfloor \frac{N+1}{2} \rfloor$ 行。34 行未改动signed main(){int n;cin >> n;for(int i = 1;i <= n;i++){int t;cin >> t;if(!q1.size()){q1.push(t);} else{if(q1.top() >= t){q1.push(t);} else{q2.push(t);}}if(i % 2 == 0) continue;while(q1.size() > i / 2 + 1){q2.push(q1.top());q1.pop();}while(q1.size() < i / 2 + 1){q1.push(q2.top());q2.pop();}cout << q1.top() << "\n";}return 0;}```## 感谢观看!