ATcoder ABC 363 A-E

A.Piling Up

# include<bits/stdc++.h>

using namespace std;


int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int r;
	cin >> r;
	if(1 <= r && r <= 99) cout << 100 - r << endl;
	else if(100 <= r && r <= 199) cout << 200 - r << endl;
	else if(200 <= r <= 299) cout << 300 - r << endl; 
	return 0;
}

B.Japanese Cursed Doll
 

# include<bits/stdc++.h>

using namespace std;


int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, t, p;
	cin >> n >> t >> p;
	int peaple[n];
	for(int i = 0;i < n;i ++){
		cin >> peaple[i];
	}
	sort(peaple, peaple + n);
	if(peaple[n - p] >= t) {
		cout << "0" << endl;
	}
	else if(peaple[n - p] < t) {
		cout << t - peaple[n - p] << endl;
	}
	return 0;
}

 

C.Avoid K Palindrome 2 
 

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    int ans = 0;
    do {
		int flag = 0;
        for(int i = 0;i < n - k + 1;i ++){
			if(s[i] == s[i + k - 1]){
        		
        		string tmp = s.substr(i, k);
//        		cout << tmp << endl;
        		string com = tmp;
        		reverse(tmp.begin(), tmp.end());
        		if(tmp == com){
        			flag = 1;
				}
			}
		}
		if(flag == 0) {
//			cout << s << endl;
			ans += 1;
		}
    } while (next_permutation(s.begin(), s.end()));
    cout << ans <<endl;
    return 0;
}

D.Palindromic Number
 

n = int(input())
tmp = list(str(n))
l = len(tmp)
if n <= 10:
    res = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    print(res[n - 1])
    exit(0)
if tmp[0] == '1' and tmp[1] != '0':  # 为偶数
    res = []
    res.extend(tmp[1:l] + tmp[1:l][::-1])
else:
    if tmp[0] == '1' and tmp[1] == '0':
        res = ['9']
        res.extend(tmp[2:l])
        res.extend(tmp[2:l - 1][::-1])
        res.extend(['9'])
    else:
        res = [str(int(tmp[0]) - 1)]
        res.extend(tmp[1:l])
        res.extend(tmp[1:l - 1][::-1])
        res.extend(str(int(tmp[0]) - 1))
sum = 0
for i in res:
    print(i, end="")

 

 E.Sinking Land
 

 

#include <bits/stdc++.h>

using namespace std;

const int H = 1010, W = 1010, Y = 100010;
bool check[H][W];
int board[H][W];
queue<int> q[Y];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h, w, y;
    cin >> h >> w >> y;
    int ans = h * w;
    for(int i = 0;i < h;i ++){
    	for(int j = 0;j < w;j ++){
    		cin >> board[i][j];
    		if(i == 0 || i == h - 1 || j == 0 || j == w - 1){
    			q[board[i][j]].push(i * w +j);
    			check[i][j] = true;
			}
		}
	}
	int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
	for(int i = 1;i <= y;i ++){
		while(!q[i].empty()){
			ans --;
			int t = q[i].front();
			int x = t / w, y = t % w; // 解码 
			q[i].pop();
			for(int j = 0;j < 4;j ++){
				int nx = x + dx[j], ny = y + dy[j];
				if(0 <= nx && nx < h && 0<= ny && ny < w){
					if(check[nx][ny] == false){
						q[max(board[nx][ny], i)].push(nx * w + ny);
						check[nx][ny] = true;
					}
				} 
			}
		}
		cout << ans << endl;
	}
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值