Codeforces Round #277 (Div. 2)

数据中心机房设备标签规范建议 机房的维护工作中,标识管理是极其重要的一部分,从基本的线缆上跳接信息的标识,到设备、机柜标识规范的实施,不同程度的体现了标识管理的重要作用。本规范适用于机房主设备、线缆、机柜(含PDU插排)、仪器仪表、动力配套设备(各类空调、消防设备、配电柜、UPS等设备)、网络口、电源插座口的标签、标识规定。动力设备的设备编号、设备名称、生产厂商及厂商技术支持热线、设备型号、设备序列号、设备使用部门、设备责任人、设备启用时间及设备保修年限、条形码。各类标签、标识可根据设备和机柜的尺寸、大小进行调整。 阅读详情

Codeforces Round #277 (Div. 2) 题解报告。。。突然发现这场给漏了,现在补上(277.5还没做)


比赛链接:http://codeforces.com/contest/486




A. Calculating Function
time limit per test
1 second
memory limit per test
256 megabytes

For a positive integer n let's define a function f:

f(n) =  - 1 + 2 - 3 + .. + ( - 1)nn

Your task is to calculate f(n) for a given integer n.

Input

The single line contains the positive integer n (1 ≤ n ≤ 1015).

Output

Print f(n) in a single line.

Sample test(s)
Input
4
Output
2
Input
5
Output
-3
Note

f(4) =  - 1 + 2 - 3 + 4 = 2

f(5) =  - 1 + 2 - 3 + 4 - 5 =  - 3


没啥可说


#include <cstdio>
int main()
{
    long long n, ans;
    scanf("%I64d", &n);
    if(n % 2 == 0)
        ans = n / 2;
    else
        ans = n / 2 - n;
    printf("%I64d\n", ans);
}




B. OR in Matrix
time limit per test
1 second
memory limit per test
256 megabytes

Let's define logical OR as an operation on two logical values (i. e. values that belong to the set {0, 1}) that is equal to 1 if either or both of the logical values is set to 1, otherwise it is 0. We can define logical OR of three or more logical values in the same manner:

where is equal to 1 if some ai = 1, otherwise it is equal to 0.

Nam has a matrix A consisting of m rows and n columns. The rows are numbered from 1 to m, columns are numbered from 1 to n. Element at row i (1 ≤ i ≤ m) and column j (1 ≤ j ≤ n) is denoted as Aij. All elements of A are either 0 or 1. From matrix A, Nam creates another matrix B of the same size using formula:

.

(Bij is OR of all elements in row i and column j of matrix A)

Nam gives you matrix B and challenges you to guess matrix A. Although Nam is smart, he could probably make a mistake while calculating matrix B, since size of A can be large.

Input

The first line contains two integer m and n (1 ≤ m, n ≤ 100), number of rows and number of columns of matrices respectively.

The next m lines each contain n integers separated by spaces describing rows of matrix B (each element of B is either 0 or 1).

Output

In the first line, print "NO" if Nam has made a mistake when calculating B, otherwise print "YES". If the first line is "YES", then also print m rows consisting of n integers representing matrix A that can produce given matrix B. If there are several solutions print any one.

Sample test(s)
Input
2 2
1 0
0 0
Output
NO
Input
2 3
1 1 1
1 1 1
Output
YES
1 1 1
1 1 1
Input
2 3
0 1 0
1 1 1
Output
YES
0 0 0
0 1 0


根据B推出A,容易发现,若B矩阵的某个点为0,则对应的A矩阵的该点所在行所在列都为0,若B矩阵的某个点为1,则对应的A矩阵的该点所在行或所在列只要有一个1即可.

因此我们可以输出话A全为1,然后根据B将A必须为0的点置为0,最后只需要判断A中1的情况是否符合要求即可


#include <cstdio>
#include <cstring>
int const MAX = 105;
int A[MAX][MAX], B[MAX][MAX], n, m;
int main()
{
    scanf("%d %d", &n, &m);
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            scanf("%d", &B[i][j]);
            A[i][j] = 1;
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(B[i][j] == 0)
            {
                for(int k = 0; k < n; k++)
                    A[k][j] = 0;
                for(int k = 0; k < m; k++)
                    A[i][k] = 0; 
            }
        }
    }
    bool ok = true, flag;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(B[i][j])
            {
                flag = false;
                for(int k = 0; k < n; k++)
                {
                    if(A[k][j])
                    {
                        flag = true;
                        break;
                    }
                }
                if(!flag)
                {
                    for(int k = 0; k < m; k++)
                    {
                        if(A[i][k])
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if(!flag)
                    ok = false;
            }
        }
    }
    if(!ok)
        printf("NO\n");
    else
    {
        printf("YES\n");
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(j != m - 1)
                    printf("%d ", A[i][j]);
                else
                    printf("%d\n", A[i][j]);
            }
        }
    }
}




C. Palindrome Transformation
time limit per test
1 second
memory limit per test
256 megabytes

Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.

There is a cursor pointing at some symbol of the string. Suppose that cursor is at position i (1 ≤ i ≤ n, the string uses 1-based indexing) now. Left and right arrow keys are used to move cursor around the string. The string is cyclic, that means that when Nam presses left arrow key, the cursor will move to position i - 1 if i > 1 or to the end of the string (i. e. position n) otherwise. The same holds when he presses the right arrow key (if i = n, the cursor appears at the beginning of the string).

When Nam presses up arrow key, the letter which the text cursor is pointing to will change to the next letter in English alphabet (assuming that alphabet is also cyclic, i. e. after 'z' follows 'a'). The same holds when he presses the down arrow key.

Initially, the text cursor is at position p.

Because Nam has a lot homework to do, he wants to complete this as fast as possible. Can you help him by calculating the minimum number of arrow keys presses to make the string to be a palindrome?

Input

The first line contains two space-separated integers n (1 ≤ n ≤ 105) and p (1 ≤ p ≤ n), the length of Nam's string and the initial position of the text cursor.

The next line contains n lowercase characters of Nam's string.

Output

Print the minimum number of presses needed to change string into a palindrome.

Sample test(s)
Input
8 3
aeabcaez
Output
6
Note

A string is a palindrome if it reads the same forward or reversed.

In the sample test, initial Nam's string is: (cursor position is shown bold).

In optimal solution, Nam may do 6 following steps:

The result, , is now a palindrome.


n个字符组成的字符串,从第p位开始将其变成回文串,求最小操作次数,操作包括左右移动和字母值的前后移动,显然改变字母值的操作次数的最小值是确定的,我们只要求出移动的最小步数即可,找到不成回文串的最左最右端点,判断即可。


#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int const MAX = 1e5 + 5;
int main()
{
    int n, p, ans = 0, l = MAX, r = -1, tmp = MAX;
    char s[MAX];
    scanf("%d %d", &n, &p);
    scanf("%s", s);
    p--;
    for(int i = 0, j = n - 1; i < j; i ++, j --)
    {
        if(s[i] != s[j])
        {
            int len = abs(s[i] - s[j]);
            ans += min(len, 26 - len);
            l = min(l, i);
            r = max(r, i);
        }
    }
    int d = r - l;
    if(ans)
    {
        tmp = min(tmp, min(abs(p - l), abs(p - r)) + d);
        int L = l, R = r;
        l = n - 1 - R;
        r = n - 1 - L;
        tmp = min(tmp, min(abs(p - l), abs(p - r)) + d);
        ans += tmp;
    }
    printf("%d\n", ans);
}



【Bug已解决】codex: rate limit 429 / Too many requests / RPM exceeded — CodeX CLI 速率限制解决方案 CodeX CLI 触发 429 速率限制(RPM/TPM/并发)的解决方案,含请求间隔、自动重试、便宜模型、Tier 升级与多 Key 轮换。 阅读详情

相关推荐

用PyCharm+Scrapy打造你的第一个爬虫:从安装到实战(附完整代码)

本文详细介绍了如何使用PyCharm和Scrapy框架从零开始构建高效网络爬虫。通过环境配置、项目创建、核心爬虫逻辑编写到数据处理与存储的完整流程,帮助Python开发者快速掌握爬虫开发技巧,并附有实战代码示例。特别适合想要学习Scrapy框架和提升爬虫技能的开发者。

weixin_29038345的博客 869

Codeforces Round #277 (Div. 2) 题解

Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outp

码代码的猿猿 2044

Docker:快速部署 Temporal 工作流引擎的技术指南

Temporal是一个开源的分布式工作流引擎,适用于复杂业务流程(如订单处理、支付流程等),提供状态持久化、自动重试、多语言SDK支持等特性。部署简单,支持Docker Compose,包含核心服务、Web UI及数据库。以TypeScript为例,开发者可快速编写工作流(如订单处理)和Worker,通过CLI或SDK启动和管理。Temporal简化了分布式系统的可靠性设计,适合电商、自动化任务等场景。

木头 642

【codeforces】Codeforces Round #277 (Div. 2) 题解

传送门:Codeforces Round #277 (Div. 2)

poursoul 1411

SKUA-GOCAD入门教程-第七节 点的创建与编辑3

本文介绍了四种从井数据创建点集的方法

江洋大葱的博客 963

C语言读取CSV文件的方法1

逗号分隔值文件格式(CSV),以纯文本形式存储表格数据,它是一种通用的、相对简单的文件格式,被用户、商业和科学广泛应用。本文介绍利用C语言标准库中的一个字符串处理函数 strtok()来对CSV文件内容进行读取的基本方法

白马负金羁 1万+

Codeforces Round #277.5 (Div. 2) JAVA版题解

Codeforces Round #277.5 (Div. 2) A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

码代码的猿猿 2301

银行监管报送系统介绍(十五):金融审计平台

金审平台主要包括基础、财务、结算、信贷和中间业务五大板块,主要服务于审计署对中国银行的各项审计任务,同时也可为行内审计、稽核检查、数据分析、总分行提供基础数据服务,为实现基础数据共享提供了有力的数据保障。2019年1月某全国性股份制商业银行收到审计署2019-23号文,文中指出为进一步提高审计数据质量,审计署审计组派员前往9家重点商业银行,就完善标准化数据的相关情况与各银行有关部门进行讨论协商。关于数据报送频率及报送内容:数据从2019年4月开始,按月报送,即于每月25日之前报送上月数据;

银行信息系统应用架构详解 2056

Codeforces Round #277 (Div. 2) D 计数问题,划分等价类

Codeforces Round #277 (Div. 2) D:

冰 919

Coze智能体开发:搭建一个解析 PDF 文件的工作流

大模型本身并不具备文件读取和解析的能力,无法直接处理文件字节流。对于支持工具调用(Function calling)的模型,扣子提供插件功能来帮助大模型调用外部工具 API,拓展大模型的能力边界。扣子插件商店提供海量官方插件和第三方插件,例如链接读取插件可以将链接对应的文件内容解析为纯文本传递给大模型。

王国平的博客 2814

Cloud Connector RFC 访问控制深度实践:为 SAP BTP ABAP environment 打通安全、可控的远程连接

本文是一份面向企业ABAP团队与平台工程团队的Cloud Connector RFC访问控制配置指南。文章详细介绍了虚拟主机/实例号、负载均衡、资源白名单等核心概念,并提供了从零开始的配置流程。主要内容包括:通过Cloud Connector建立安全隧道的价值(零暴露、最小权限)、两种连接类型(无负载均衡/带负载均衡)的配置方法、资源白名单设置技巧,以及两个典型应用场景(Custom Code Migration远程检查与BAPI调用)的实操案例。指南基于SAP官方文档,包含落地经验与避坑建议,可帮助团队快

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 146

Codeforces Round #277.5 (Div. 2)

由于时间,身体,电脑等问题

CHEATBEATER 684

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

【codeforces】Codeforces Round #277 (Div. 2) 解读

门户:Codeforces Round #277 (Div. 2) 486A. Calculating Function 裸公式= = #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;algorithm&gt; using namespace std ; typedef long long LL...

weixin_34200628的博客 159

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

【codeforces】Codeforces Round #277.5 (Div. 2)

传送门:【codeforces】Codeforces Round #277.5 (Div. 2) A:

poursoul 1172

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Codeforces Round #277 (Div. 2) b

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34220623的博客 79

Codeforces Round #277.5 (Div. 2) 解题报告

Codeforces Round #277.5 (Div. 2)jieti

gwq5210的专栏 718

Codeforces Round #277 (Div. 2) c

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34364135的博客 85

Codeforces Round #277.5 (Div. 2) b

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34405925的博客 73

Codeforces Round #277.5 (Div. 2) a

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34279184的博客 98

Codeforces Round #277.5 (Div. 2) d

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33966095的博客 79

Codeforces Round #277 (Div. 2)D(树形DP计数类)

Codeforces Round #277 (Div. 2)D(树形DP计数类) D. Valid Sets time limit per test 1 second memory limit per test 256 megabytes input standard input o...

weixin_30716725的博客 160

“Wishare杯”南邮第八届大学生程序设计竞赛之现场决赛 题解报告

“Wishare杯”南邮第八届大学生程序设计竞赛之网络预赛 题解报告

Tc的专栏 6838
上一篇: 南邮2014程序设计新生赛暨蓝桥杯校内自主选拔赛2
下一篇: HDU 1069 Monkey and Banana (线性dp 完全背包)
_TCgogogo_
博客等级 码龄12年 615粉丝 1081原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值