【无标题】AtCoder Beginner Contest 224(A-F)

AtCoder Beginner Contest 224(A-F)

知识点整理:

题号 知识点 备注
A
B
C
D 基础DP 矩阵最大路径和变种
E 状态机DP
F 状压DP
G ?
H ?

A - QQ solver

题意

给你三个字符组成的乘法表达式, 求计算结果

题解

用scanf读入整数

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b;
  scanf("%dx%d", &a, &b);
  printf("%d\n", a*b);return 0;
}

B - Caesar Cipher

题意

给定两个字符串AAABBB, 问能否通过字母的轮换把A变成B

题解

一共就26种情况, 暴力枚举, 需注意char的最大范围是128, 有可能溢出.

#include <bits/stdc++.h>

using namespace std;

int main() {
   
   
    string a, b;
    cin >> a >> b;

    bool flag = false;

    for (int i = 0; i < 26; i++) {
   
   
        string c = a;
        for (int j = 0; j < c.size(); j++) {
   
   
            c[j] = (char)(a[j] + i);
            if (c[j] > 'z' || c[j] < 0) {
   
   
                c[j] = (char) (a[j] - 26 + i);
            }
        }

        if (c == b) {
   
   
            flag = true;
            break;
        }
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

C - Graph Isomorphism

题意

两个图是否同构

题解

8个点, 一共就8!种情况, 暴力枚举

#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int a[N][N];
int b[N][N];
struct node {
   
   
    int x, y;
} c[N];
int n, m;
int vis[N];
int res[9] = {
   
   0, 1, 2, 3, 4, 5, 6, 7, 8};
int main() {
   
   
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
   
   
        int x, y;
        cin >> x >> y;
        a[x][y] = 1;
        a[y][x] = 1;
        c[i] = {
   
   x, y};
    }
    for (int i = 1; i <= m; i++) {
   
   
        int x, y;
        cin >> x >> y;
        b[x][y] = 1;
        b[y][x] = 1;
    }
    bool flag = 0;
    int cnt = 0;
    int dex = 1;
    for (int i = 1; i <= m; i++) {
   
   
        if (b[res[c[i].x]][res[c[i].y]] == 0 &&
            b[res[c[i].y]][res[c[i].x]] == 0) {
   
   
            dex = 0;
            break;
        }
    }
    if(dex==1) {
   
   
        puts("Yes");
        return 0;
    }
    while (next_permutation(res + 1, res + n + 1)) {
   
   
        int now = 1;
        for (int i = 1; i <= m; i++) {
   
   
            if (b[res[c[i].x]][res[c[i].y]] == 0 &&
                b[res[c[i].y]][res[c[i].x]] == 0) {
   
   
                now = 0;
                break;
            }
        }
        if (now == 1) {
   
   
            flag = 1;
            break;
        }
    }

    if (flag)
        
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值