#include<bits/stdc++.h>usingnamespace std;#defineintlonglongstructBIT{constint n;vector<int> tree;BIT(int n):n(n),tree(n +1){};// 询问前x个数的和intQuery(int x){int res =0;for(int i = x; i >0; i -=(i &-i)) res += tree[i];return res;}// 第l个位置+zvoidModify(int l,int z){if(l <=0)return;for(int i = l; i <= n; i +=(i &-i)) tree[i]+= z;}// 区间求和intrangeQuery(int l,int r){returnQuery(min(n, r))-Query(max(0ll, l -1));}};voidsolve(){int n; cin >> n;vector<int>a(n +1),pos(n +1);for(int i =1; i <= n; i ++){cin >> a[i];pos[a[i]]= i;}vector<vector<int>>mem(n +1);vector<bool>st(n +1);for(int i =1; i <= n; i ++){int t = pos[a[i]-1]+1;if(i >= t){mem[t].push_back(i);st[a[i]]=true;}}BIT bit(n);int ans =0;for(int i =1; i <= n; i ++){for(auto t : mem[i]) bit.Modify(a[t],1);if(st[a[i]]) bit.Modify(a[i],-1);if(a[i -1]+1<= a[i]-1) ans += bit.rangeQuery(a[i -1]+1, a[i]-1);}cout << ans <<'\n';}signedmain(){ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int t =1;// cin >> t;while(t --){solve();}}
#include<bits/stdc++.h>usingnamespace std;#defineintlonglongtypedef pair<int,int> PII;voidsolve(){vector<int>cnt(6);for(int i =1; i <=5; i ++) cin >> cnt[i];int ans =0;int minn =min(cnt[1], cnt[5]);ans += minn;cnt[1]-= minn; cnt[5]-= minn;minn =min(cnt[2], cnt[4]);ans += minn;cnt[2]-= minn; cnt[4]-= minn;ans += cnt[3]/2;cnt[3]%=2;auto cal =[&](int id){int need =6- id;int nw =0;for(int i =1; i < id; i ++){if(!cnt[i])continue;int minn =min((nw + cnt[i])/ need, cnt[id]);cnt[i]-=(minn * need - nw); cnt[id]-= minn;for(int j =1; j < i; j ++) cnt[j]=0;ans += minn;nw = cnt[i];}if(nw !=0&& cnt[id]){int need =6- nw;int c = need / id;if(cnt[id]>= c){need -= c * id;if(need ==0){cnt[id]-= c;ans ++;for(int i =1; i < id; i ++) cnt[i]=0;}else{if(cnt[id]>= need){cnt[id]-= need;ans ++;for(int i =1; i < id; i ++) cnt[i]=0;}}}}if(id ==5) ans += cnt[id]/2;elseif(id ==4|| id ==2) ans += cnt[id]/3;elseif(id ==1) ans += cnt[id]/6;cnt[id]=0;};if(cnt[1]&& cnt[2]&& cnt[3]){cnt[1]-=1; cnt[2]-=1; cnt[3]-=1;ans ++;if(cnt[2])cal(2);if(cnt[1])cal(1);}elseif(cnt[2]&& cnt[3]&& cnt[5]){cnt[5]--; cnt[3]--;ans ++;if(cnt[5])cal(5);if(cnt[2])cal(2);}elseif(cnt[2]&& cnt[3]){if(cnt[2]>=2){cnt[2]-=2; cnt[3]--;ans ++;}if(cnt[2])cal(2);}else{for(int i =5; i >=1; i --){if(cnt[i])cal(i);}}cout << ans <<'\n';}signedmain(){ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);int t =1;cin >> t;while(t --){solve();}}
Problem E. L 型覆盖检查器(模拟)
#include<bits/stdc++.h>usingnamespace std;#defineintlonglongstring g[510];
pair<int,int> dx[]={{-1,0},{0,1},{0,-1},{-1,0}};
pair<int,int> dy[]={{0,1},{1,0},{1,0},{0,-1}};char fx[]={'D','L','R','D'};char fy[]={'L','U','U','R'};voidsolve(){int n, m;cin >> n >> m;for(int i =1; i <= n; i++){cin >> g[i];g[i]=" "+ g[i];}if(g[1][m]!='.'){cout <<"No"<< endl;return;}vector<pair<int,int>> cc;for(int i =1; i <= n; i++){for(int j =1; j <= m; j++){if(g[i][j]=='C')cc.push_back({i, j});}}vector<vector<int>>st(n +1, vector<int>(m +1,0));for(int i =0; i < cc.size(); i++){int a = cc[i].x, b = cc[i].y;st[a][b]= i +1;for(int j =0; j <4; j++){int x1 = a + dx[j].x, y1 = b + dx[j].y;int x2 = a + dy[j].x, y2 = b + dy[j].y;if(x1 <1|| x1 > n || x2 <1|| x2 > n)continue;if(y1 <1|| y1 > m || y2 <1|| y2 > m)continue;if(st[x1][y1]!=0)continue;if(st[x2][y2]!=0)continue;if(g[x1][y1]== fx[j]&& g[x2][y2]== fy[j]){st[x1][y1]= i +1, st[x2][y2]= i +1;}}}bool flag =0;map<int,int> jk;for(int i =1; i <= n; i++){for(int j =1; j <= m; j++){if(i ==1&& j == m)continue;if(st[i][j]==0){cout <<"No"<< endl;return;}jk[st[i][j]]++;}}for(auto bb : jk){if(bb.y !=3){cout <<"No"<< endl;return;}}cout <<"Yes"<< endl;}signedmain(){ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int t =1;cin >> t;while(t--){solve();}}
确保模型的可靠性和性能
1. Precision
Precision is a metric that measures how accurate the model’s positive predictions are. It calculates the ratio of true positives (correctly predicted positive cases) to the total number of predicted positives (both tr…
官网:Vant 4 - A lightweight, customizable Vue UI library for mobile web apps.
Vant组件库: 基础组件 按钮、图标、布局、提示信息等 表单组件 日历、复选框、时间选择、输入框、评分等 反馈组件 弹出框、加载、下拉菜单、消息提示、下拉刷新、滚动…