A
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a+3);
int b = a[0] + a[1];
int ans = 0;
if(a[2] > b) ans = (a[2] - b) + 1;
else if(a[2] == b) ans = 1;
else ans = 0;
cout << ans << endl;
return 0;
}
B
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a,0,sizeof(a))
#define line cout<<"-----------------"<<endl;
typedef long long ll;
const int maxn = 1e5+10;
const int MAXN = 1e6+10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int N = 1010;
int solve(ll n){
int cnt = 0;
while(n){
if(n%2 == 1) cnt ++;
n /= 2;
}
return cnt;
}
int main(){
/*for(int i = 0; i <= 10; i++){
int cnt = 0;
for(int j = 0; j <= i; j++){
if((i - j) == (i ^ j)) cnt ++;
}
printf("%d ", cnt);
}*/
int t;
cin >> t;
while(t--){
ll a, num;
cin >> a;
int tot = solve(a);
num = 1 << tot;
cout << num << endl;
}
return 0;
}
C
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a,0,sizeof(a))
#define line cout<<"-----------------"<<endl;
typedef long long ll;
const int maxn = 1e5+10;
const int MAXN = 1e6+10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int N = 1010;
char s[maxn];
int main(){
int n;
scanf("%d %s", &n, s);
sort(s, s+n);
puts(s);
return 0;
}
D
#include<bits/stdc++.h>
using namespace std;
int n,m;
int x,y;
int ln,rn;
const int maxn = 2336;
char maze[maxn][maxn];
bool vis[maxn][maxn];
struct node{
int x,y;
int l,r;
node (int _x, int _y, int _l, int _r) {x = _x, y = _y, l = _l, r = _r;}
};
bool check(int x,int y){
return x >= 1 && x <= n && y >= 1 && y <= m;
}
int dir[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
int LL[maxn][maxn],RR[maxn][maxn];
int ans;
void bfs(int sx, int sy){
queue<node> q;
q.push(node(sx,sy,ln,rn));
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
LL[i][j] = RR[i][j] = -1;
}
}
while(!q.empty()){
node rt = q.front();
q.pop();
if(!vis[rt.x][rt.y]){
ans++;
vis[rt.x][rt.y] = 1;
}
for(int i = 0; i < 4; i++){
int dx = rt.x + dir[i][0];
int dy = rt.y + dir[i][1];
int ll = rt.l;
int rr = rt.r;
if(i == 1) --ll;
if(i == 0) --rr;
if(check(dx,dy)&&maze[dx][dy] == '.' && ll >= 0 && rr >= 0 && (ll > LL[dx][dy] || rr > RR[dx][dy])) {
q.push(node(dx,dy,ll,rr));
LL[dx][dy] = ll;
RR[dx][dy] = rr;
}
}
}
}
int main(){
ans = 0;
cin >> n >> m >> x >> y >> ln >> rn;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> maze[i][j];
}
}
bfs(x, y);
cout << ans << endl;
return 0;
}