2021CCPC女生赛

Hanser·2022-01-11 21:20·95 次阅读

2021CCPC女生赛

A. 公交路线

复制代码
#include <bits/stdc++.h>
using namespace std;
int n, x, y, m;
int k[20], p[20];
int main()
{
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) cin >> k[i];
    cin >> m;
    for (int i = 1; i <= m; i++) cin >> p[i];
    bool f1 = 1, f2 = 1;
    for (int i = x + 1; i <= x + m; i++)
        if (k[i] != p[i - x]) f2 = 0;
    for (int i = x - 1; i >= x - m; i--)
        if (k[i] != p[x - i]) f1 = 0;
    if (f1 == 1 && f2 == 1) cout << "Unsure";
    else if (f1 == 1 && y < x) cout << "Right";
    else if (f2 == 1 && x < y) cout << "Right";
    else cout << "Wrong";
    return 0;
}
View Code
复制代码

B. 攻防演练

C. 连锁商店

D. 修建道路

复制代码
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
ll ans;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) 
        ans += max(a[i], a[i + 1]);
    cout << ans;
    return 0;
}
View Code
复制代码

E. 被遗忘的计划

F. 地图压缩

G. 3G网络

复制代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i = 0, x, y; i < n; i++) cin >> x >> y;
    double ans = 1.0 / n;
    printf("%.12f", ans);
    return 0;
}
View Code
复制代码

H. 4G网络

I. 驾驶卡丁车

复制代码
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, m, q, x, y;
string s;
bool vis[N][N];
int path[8][2] = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};
bool check(int d)
{
    if (d == 1 || d == 3 || d == 5 || d == 7)
    {
        if ((vis[x + path[(d + 7) % 8][0]][y + path[(d + 7) % 8][1]]) && (vis[x + path[(d + 1) % 8][0]][y + path[(d + 1) % 8][1]]))
            return true;
    }
    return false;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> s;
        for (int j = 0; j < m; j++)
            if (s[j] == '.') vis[i][j + 1] = 0;
            else if (s[j] == '#') vis[i][j + 1] = 1;
            else vis[i][j + 1] = 0, x = i, y = j + 1;
    }
    cin >> q >> s;
    int v = 0, d = 0;
    for (int i = 0; i < q; i++)
    {
        bool f = 1;
        if (s[i] == 'L') d = (d + 7) % 8;
        else if (s[i] == 'R') d = (d + 1) % 8;
        else if (s[i] == 'U') v++;
        else v = max(v - 1, 0);
        int tx, ty;
        for (int j = 0; j < v; j++)
        {
            tx = x + (path[d][0]), ty = y + (path[d][1]);
            if (vis[tx][ty] == 1 || tx <= 0 || ty <= 0 || tx > n || ty > m || check(d))
            {
                printf("Crash! %d %d\n", x, y);
                v = f = 0;
                break;
            }
            x = tx, y = ty;
        }
        if (f) printf("%d %d\n", x, y);
    }
    return 0;
}
View Code
复制代码

J. 最大权边独立集

K. 音乐游戏

复制代码
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    int n, cnt = 0;
    cin >> n;
    char ch;
    while (cin >> ch) if (ch == '-') cnt++;
    cout << cnt;
    return 0;
}
View Code
复制代码

 

posted @   ゼロツー  阅读(95)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
Live2D Title
欢迎阅读『2021CCPC女生赛』
点击右上角即可分享
微信分享提示