EPIC Institute of Technology Round August 2024 (Div. 1 + Div. 2)(A-C)

A. Distanced Coloring

Problem - A - Codeforces

1.1翻译

你从一个神秘的来源收到了一个 n×mn×m 网格。这个来源还给了你一个神奇的正整数常数 k 。

消息来源告诉你用一些颜色给网格着色,并满足以下条件:

  • 如果 (x1 , y1) (x1 , y1) , (x2 , y2) (x2 , y2) 是两个颜色相同的单元格,那么就保证max(|x1−x2|,|y1−y2|) ≥ k

请找出给网格着色所需的最少颜色数。

1.2思路

对于任何 k×k 的子网格,我们使用的颜色必须是成对不同的。因此,最少为 min(n,k)⋅min(m,k) 

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

typedef pair<int,int> PII;

const int N = 300010, M = 600020; 

void solve()
{
    int n,m,k;
    cin >> n >> m >> k;
    int ans = 0;
    ans = ans + min(k,n) * min(m,k);
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int tt;
    cin >> tt;
    //tt = 1;
    while(tt --)
    {
        solve();
    }   
}

B. Removals Game

Problem - B - Codeforces

2.1翻译

爱丽丝得到了[1,2,…,n]的a 排列,鲍勃得到了[1,2,…,n]的 b排列。他们打算用这些数组玩一个游戏。

在每个回合中,会依次发生以下事件:

  • 爱丽丝选择数组中的第一个或最后一个元素,并将其从数组中删除;
  • 鲍勃选择自己数组中的第一个或最后一个元素,并将其从数组中移除。

游戏继续进行 n−1轮,之后两个数组都将只剩下一个元素:数组 a 中的 x 和数组 b 中的 y 。

如果是 x=y,鲍勃获胜;否则,爱丽丝获胜。求如果双方都以最佳方式下棋,哪一方会赢。

2.2思路

爱丽丝删除什么鲍勃就删除什么,直到鲍勃不能删除

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

typedef pair<int,int> PII;

const int N = 300010, M = 600020; 

void solve()
{
    int n;
    cin >> n;
    std::vector<int> arr(n + 10);
    std::vector<int> brr(n + 10);
    for(int i = 1; i <= n; i ++)
    {
        cin >> arr[i];
    }
    for(int i = 1; i <= n; i ++)
    {
        cin >> brr[i];
    }
    int lefta = 1;
    int righta = n;
    int leftb = 1;
    int rightb = n;
    int flag = 0;
    while(lefta <= righta && leftb <= rightb)
    {
        if((arr[lefta] != brr[rightb] && arr[lefta] != brr[leftb]) || (arr[righta] != brr[rightb] && arr[righta] != brr[leftb]))
        {
            cout <<"Alice" << endl;
            return;
        }
        else if(arr[lefta] == brr[lefta])
        {
            lefta++;
            leftb++;
        }
        else if(arr[lefta] == brr[rightb])
        {
            lefta++;
            rightb--;
        }
        else if(arr[righta] == brr[rightb])
        {
            righta--;
            rightb--;
        }
        else if(arr[righta] == brr[leftb])
        {
            righta--;
            leftb++;
        }
    }
    cout << "Bob" << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int tt;
    cin >> tt;
    //tt = 1;
    while(tt --)
    {
        solve();
    }   
}

C. Black Circles

Problem - C - Codeforces

3.1翻译

二维平面上有 n 个圆。以 (xi,yi) 为圆心的圆有i个。最初,所有圆的半径都是 0 。

圆的半径以每秒 1个单位的速度增加。

你现在的位置是(xs,ys), 你的目标是到达 (xt,yt)而不触及任何圆的周长(包括到达 (xt,yt) 的时刻)。您可以朝任何方向移动。但是,你的速度限制为每秒 1 个单位。

请判断这是否可行。

3.2思路

单独考虑每一个圆,沿着直线走向目标。如果某个圆(CB <= AB)先到达目标,无论走哪条路,都没有成功的机会。

当CB > AB 可以证明我们在直线通往目标的路上不会经过任何圆圈。

假设在D点拦截,则AD = CD,又因为 CD > BC - BD,则AD >= BC - BD,则CB <= AB,矛盾

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

typedef pair<int,int> PII;

const int N = 300010, M = 600020; 

void solve()
{
    int n;
    cin >> n;
    std::vector<int> arr(n + 10);
    std::vector<int> brr(n + 10);  
    for(int i = 1; i <= n; i ++)
    {
        int x,y;
        cin >> x >> y;
        arr[i] = x;
        brr[i] = y;
    }
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int d = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    for(int i = 1; i <= n; i ++)
    {
        int dis = (arr[i] - x2)* (arr[i] - x2) + (brr[i] - y2) * (brr[i] - y2);
        if(dis > d)
        {
            continue;
        }
        else
        {
            cout <<"NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int tt;
    cin >> tt;
    //tt = 1;
    while(tt --)
    {
        solve();
    }   
}

  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值