Educational Codeforces Round 65 (Rated for Div. 2)

本文提供了四道编程竞赛题目,包括电话号码验证、交互式数字序列猜测、新闻传播路径优化和双色括号序列染色问题。每道题目详细描述了输入输出格式、样例测试用例以及解题思路。通过这些题目,参赛者可以锻炼他们的算法设计和问题解决能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Telephone Number
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.

You are given a string s of length n, consisting of digits.

In one operation you can delete any character from string s. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.

You need to determine whether there is such a sequence of operations (possibly empty), after which the string s becomes a telephone number.

Input
The first line contains one integer t (1≤t≤100) — the number of test cases.

The first line of each test case contains one integer n (1≤n≤100) — the length of string s.

The second line of each test case contains the string s (|s|=n) consisting of digits.

Output
For each test print one line.

If there is a sequence of operations, after which s becomes a telephone number, print YES.

Otherwise, print NO.

Example
inputCopy
2
13
7818005553535
11
31415926535
outputCopy
YES
NO
Note
In the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535.

题意:定义一个数字串串为一个手机号当且仅当这个数字串以8开头并且长度为11,现在给出t组数据,每组数据给出一个数字串,询问这个数字串能否经过删除一些数字变成字符串
题解:只要从8出现的位置到末尾的长度>=11即可

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
int main(){
   
    int t;
    scanf("%d",&t);
    while(t--){
   
        int n;
        scanf("%d",&n);
        char ch[105];
        scanf("%s",ch+1);
        int f=0;
        for(int i=1;i<=n;i++){
   
            if(ch[i]=='8'&&n-i+1>=11){
   
                f=1;
                break;
            }
        }
        if(f)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

B. Lost Numbers
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming language, consult its documentation. You may also refer to the guide on interactive problems: https://codeforces.com/blog/entry/45307.

The jury guessed some array a consisting of 6 integers. There are 6 special numbers — 4, 8, 15, 16, 23, 42 — and each of these numbers occurs in a exactly once (so, a is some permutation of these numbers).

You don’t know anything about their order, but you are allowed to ask up to 4 queries. In each query, you may choose two indices i and j (1≤i,j≤6, i and j are not necessarily distinct), and you will get the value of ai⋅aj in return.

Can you guess the array a?

The array a is fixed beforehand in each test, the interaction program doesn’t try to adapt to your queries.

Interaction
Before submitting the answer, you may ask up to 4 queries. To ask a query, print one line in the following format: ? i j, where i and j should be two integers such that 1≤i,j≤6. The line should be ended with a line break character. After submitting a query, flush the output and read the answer to your query — one line containing one integer ai⋅aj. If you submit an incorrect query (or ask more than 4 queries), the answer to it will be one string 0. After receiving such an answer, your program should terminate immediately — otherwise you may receive verdict “Runtime error”, “Time limit exceeded” or some other verdict instead of “Wrong answer”.

To give the answer, your program should print one line ! a1 a2 a3 a4 a5 a6 with a line break in the end. After that, it should flush the output and terminate gracefully.

Example
inputCopy
16
64
345
672
outputCopy
? 1 1
? 2 2
? 3 5
? 4 6
! 4 8 15 16 23 42
Note
If you want to submit a hack for this problem, your test should contain exactly six space-separated integers a1, a2, …, a6. Each of 6 special numbers should occur exactly once in the test. The test should be ended with a line break character.

题意:一道简单的交互题,只要会写交互格式即可。有6个数字4, 8, 15, 16, 23, 42的一个排列,要求你经过4次询问得出这个排列,询问格式为"? a b"得到a*b的值。第一次询问"? 1 2",第二次"? 1 3"即可得出a1,a2,a3的值,第三次询问"? 4 5",第四次询问"? 4 6"即可得出a4,a5,a6的值

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
int a[7]={
   0,4, 8, 15, 16, 23, 42 };
int a1,a2,a3,a4,a5,a6;
int main(){
   
    cout<<"? 1 2"<<endl;
    fflush(stdout);
    int x,y;
    cin>>x;
    cout<<"? 1 3"<<endl;
    fflush(stdout);
    cin>>y;
    for(int i=1;i<=6;i++){
   
        for(int j=1;j<=6;j++){
   
            for(int k=1;k<=6;k++){
   
                if((i!=j&&i!=k&&j!=k)&&(a[i]*a[j]==x&&a[i]*a[k]==y)){
   
                    a1=a[i];
                    a2=a[j];
                    a3=a[k];
    
"educational codeforces round 103 (rated for div. 2)"是一个Codeforces平台上的教育性比赛,专为2级选手设计评级。以下是有关该比赛的回答。 "educational codeforces round 103 (rated for div. 2)"是一场Codeforces平台上的教育性比赛。Codeforces是一个为程序员提供竞赛和评级的在线平台。这场比赛是专为2级选手设计的,这意味着它适合那些在算法和数据结构方面已经积累了一定经验的选手参与。 与其他Codeforces比赛一样,这场比赛将由多个问题组成,选手需要根据给定的问题描述和测试用例,编写程序来解决这些问题。比赛的时限通常有两到三个小时,选手需要在规定的时间内提交他们的解答。他们的程序将在Codeforces的在线评测系统上运行,并根据程序的正确性和效率进行评分。 该比赛被称为"educational",意味着比赛的目的是教育性的,而不是针对专业的竞争性。这种教育性比赛为选手提供了一个学习和提高他们编程技能的机会。即使选手没有在比赛中获得很高的排名,他们也可以从其他选手的解决方案中学习,并通过参与讨论获得更多的知识。 参加"educational codeforces round 103 (rated for div. 2)"对于2级选手来说是很有意义的。他们可以通过解决难度适中的问题来测试和巩固他们的算法和编程技巧。另外,这种比赛对于提高解决问题能力,锻炼思维和提高团队合作能力也是非常有帮助的。 总的来说,"educational codeforces round 103 (rated for div. 2)"是一场为2级选手设计的教育性比赛,旨在提高他们的编程技能和算法能力。参与这样的比赛可以为选手提供学习和进步的机会,同时也促进了编程社区的交流与合作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值