You are the gym teacher in the school. There are nn students in the row. And there are two rivalling students among them. The first one is in position aa, the second in position bb. Positions are numbered from 11 to nn from left to right. Since they…
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1]\)中的位置上的字符. 题解:不难发现,\(s\)中的奇数位字符就是我们要的答案. 代码: int t; int n; char s[N]; int main() { //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); t=read(); wh…
Educational Codeforces Round 76 (Rated for Div. 2) E. The Contest(dp+线段树) 题目链接 题意: 给定3个人互不相同的多个数字,可以把数字移动给别人,问最少移动几次后可以使第一个人的数字为1~m1,第二个人m1~m2,第三个人m2~n(可以没有数字) 题解: 设c[1][i]为第一个人m1为i时需要移动的次数,c[3][i]为m2为i是第三个人需要操作的次数,当其他两个人数字合法时,第二个人的数字也会合法.枚举第一个人的每个i,…
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序. 输出最小操作次数 dp: #include<bits/stdc++.h> using namespace std; ; ]; int a[M]; ///dp[i][0]表示前i个数全属于第一个数组所要花费的最小代价 ///dp[i][1]表示前i个数全属于第一.二个数组所要花费的最小代价 //…
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #defi…
E. The Contest A team of three programmers is going to play a contest. The contest consists of…
D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of…
B. Magic Stick Recently Petya walked in the forest and found a magic stick. Since Petya really likes numbers, the first thing he learned was spells for changing numbers. So far, he knows only two spells that can be applied to a positive integer: If t…