ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

2021CCPC女生赛

2022-01-11 21:33:11  阅读:156  来源: 互联网

标签:女生 tx vis int cin 2021CCPC ++ path


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

 

标签:女生,tx,vis,int,cin,2021CCPC,++,path
来源: https://www.cnblogs.com/ltzmgby/p/15790148.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有