正文
增加 12 行删除 12 行
20 行未改动2122232425262728293031323394 行未改动128129130131132133134135136104 行未改动全部展开24124224324424524624724824922 行未改动272273274275276277278279280200 行未改动全部展开48148248348448548648748848940 行未改动53053153253353453553653753849 行未改动58858959059159259359459559634 行未改动6316326336346356366376386396406416426436446456466476487 行未改动20 行未改动### 题意在⼀条数轴上有 个村庄,每个村庄的位置是⼀个整数。每个村庄的“邻域”定义为:数轴上所有离这个村庄⽐离其他任何村庄都近的点。若某个点与两个村庄等距,则同时 属于两个村庄的邻域。对于最左和最右的村庄,邻域⼤⼩视为⽆限⼤。对其他村庄,邻域⼤⼩等于其左边界和右边界之间的距离。求所有具有 有限邻域 的村庄中, 最⼩的邻域⼤⼩ ,结果保留⼀位⼩数。### 正解94 行未改动for(int i = 1; i <= n; i ++) {cin >> A[i];MN[i] = 1e18 + 10;}MN[1] = 0;for(int I = 2; I < n; I ++) {int res = 0;for(int l = I - 1, r = I + 1; l >= 1 && r <= n; l --, r ++) {104 行未改动全部展开{long long n,c;cin>>n>>c;for(long long i=1;i<=n;i++){long long x;cin>>x;t[x]++;}long long ans=n*(n-1)*(n-2)/6;long long bg=0,zc=c/2,sum=0;22 行未改动sum+=t[i]*(t[i]-1)*(t[i]-2)/6;}cout<<ans-sum;return 0;}```我的实现:200 行未改动全部展开cnt+=(s[L]-s[r+2])*a[r+1];r++;}}cout<<ans;return 0;}```40 行未改动} else {int HLF = C / 2, sum = 0;for(int c = HLF + 1; c < C; c ++) {int cp = c - C / 2 + 1;sum += num[c] * (S[HLF - 1] - S[cp - 1]);}ans += num[0] * sum;49 行未改动```c++for(int i = 1; i < S.size(); i ++) {char c = S[i];if('b' == c) lst[1] = i;if('e' == c) lst[2] = lst[1];if('s' == c) lst[3] = lst[2];if('s' == c) lst[4] = lst[3];34 行未改动cin >> S;S = ' ' + S;for(int i = 1; i < S.size(); i ++) {char c = S[i];if('b' == c) lst[1] = i;if('e' == c) lst[6] = lst[5], lst[2] = lst[1];if('s' == c) lst[4] = lst[3], lst[3] = lst[2];if('i' == c) lst[5] = lst[4];dp[i] = dp[lst[6] - 1] + lst[6];ans += dp[i];}cout << ans;return 0;}7 行未改动20 行未改动2122232425262728293031323394 行未改动128129130131132133134135136104 行未改动全部展开24124224324424524624724824922 行未改动272273274275276277278279280200 行未改动全部展开48148248348448548648748848940 行未改动53053153253353453553653753849 行未改动58858959059159259359459559634 行未改动6316326336346356366376386396406416426436446456466476487 行未改动20 行未改动### 题意在⼀条数轴上有 个村庄,每个村庄的位置是⼀个整数。每个村庄的“邻域”定义为:数轴上所有离这个村庄⽐离其他任何村庄都近的点。若某个点与两个村庄等距,则同时 属于两个村庄的邻域。对于最左和最右的村庄,邻域⼤⼩视为⽆限⼤。对其他村庄,邻域⼤⼩等于其左边界和右边界之间的距离。求所有具有 有限邻域 的村庄中, 最⼩的邻域⼤⼩ ,结果保留⼀位⼩数。### 正解94 行未改动for(int i = 1; i <= n; i ++) {cin >> A[i];MN[i] = 1e18 + 10;}MN[1] = 0;for(int I = 2; I < n; I ++) {int res = 0;for(int l = I - 1, r = I + 1; l >= 1 && r <= n; l --, r ++) {104 行未改动全部展开{long long n,c;cin>>n>>c;for(long long i=1;i<=n;i++){long long x;cin>>x;t[x]++;}long long ans=n*(n-1)*(n-2)/6;long long bg=0,zc=c/2,sum=0;22 行未改动sum+=t[i]*(t[i]-1)*(t[i]-2)/6;}cout<<ans-sum;return 0;}```我的实现:200 行未改动全部展开cnt+=(s[L]-s[r+2])*a[r+1];r++;}}cout<<ans;return 0;}```40 行未改动} else {int HLF = C / 2, sum = 0;for(int c = HLF + 1; c < C; c ++) {int cp = c - C / 2 + 1;sum += num[c] * (S[HLF - 1] - S[cp - 1]);}ans += num[0] * sum;49 行未改动```c++for(int i = 1; i < S.size(); i ++) {char c = S[i];if('b' == c) lst[1] = i;if('e' == c) lst[2] = lst[1];if('s' == c) lst[3] = lst[2];if('s' == c) lst[4] = lst[3];34 行未改动cin >> S;S = ' ' + S;for(int i = 1; i < S.size(); i ++) {char c = S[i];if('b' == c) lst[1] = i;if('e' == c) lst[6] = lst[5], lst[2] = lst[1];if('s' == c) lst[4] = lst[3], lst[3] = lst[2];if('i' == c) lst[5] = lst[4];dp[i] = dp[lst[6] - 1] + lst[6];ans += dp[i];}cout << ans;return 0;}7 行未改动