AtCoder Beginner Contest 250

AtCoder Beginner Contest 250

A - Adjacent Squares

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios::sync_with_stdio(false),cin.tie(nullptr);
    int h,w,r,c;
    cin>>h>>w>>r>>c;
    int dir[][2]={1,0,0,1,-1,0,0,-1};
    int cnt=0;
    for(int i=0;i<4;i++){
        int x=r+dir[i][0],y=c+dir[i][1];
        if(x>=1&&x<=h&&y>=1&&y<=w)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

B - Enlarged Checker Board

#include <bits/stdc++.h>

#pragma GCC optimize(2)
using namespace std;
//#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
//const int inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }

const int maxn = 1e2 + 10;
const int N = 6e6 + 100;

int dp[maxn][maxn];

void solve() {
    int n,a,b;
    cin>>n>>a>>b;
    for (int i = 0; i < n*a; ++i) {
        for (int j = 0; j < n*b; ++j) {
            cout<<(i/a+j/b & 1?'#':'.');
        }
        cout<<endl;
    }
}

signed main() {
    //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();//cout<<"\n";
    }
    return 0;
}

//12341
//14321
//

C - Adjacent Swaps

#include <bits/stdc++.h>

#pragma GCC optimize(2)
using namespace std;
//#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
//const int inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }

const int maxn = 1e6 + 10;
const int N = 6e6 + 100;

int a[maxn],b[maxn];

void solve() {
    int n,q;
    cin>>n>>q;
    for (int i = 0; i <=n; ++i) {
        a[i]=b[i]=i;
    }
    while (q--){
        int x;
        cin>>x;
        int opt=a[x];
        if(opt==n) opt=n-1;
        swap(b[opt],b[opt+1]);
        swap(a[b[opt]],a[b[opt+1]]);
    }

    for (int i = 1; i <=n; ++i) {
        cout<<b[i]<<" ";
    }
}

signed main() {
    //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
//    cin >> _;
    while (_--) {
        solve();//cout<<"\n";
    }
    return 0;
}

//12341
//14321
//
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值