CF1141D Colored Boots】的更多相关文章

There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character li stands for the color of the i-th left b…
There are nn left boots and nn right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings ll and rr, both of length nn. The character lili stands for the color of the ii-t…
题目来自Codeforce 1141Dhttp://codeforces.com/problemset/problem/1141/D 因为是全英文题面,就先简单的阐述一下题面. 首先输入一个数n,然后输入两个长度为n的字符串,我们需要做的就是对两个字符串的每个字符从1到n编号,然后对两个字符串的所有字符进行一对一的匹配,如果两个字符串中有字符相同,则匹配成功,输出两个字符的对应编号,其中?可以和任意字符匹配,问最多能匹配多少个字符,输出最优解. 解题思路 这个题如果直接遍历不用说,肯定超时,但是…
链接:https://codeforces.com/contest/1141/problem/D 题意: 给连个n长度的字符串. 求两个字符串相同字符对应位置的对数,并挨个打印. 字符:?可以代替任何字符. 思路: 对第一个字符串建立字符与位置的映射. 再处理第二个字符. 同时第二个字符中的‘?'不做处理. 全部遍历完了以后,再处理?的情况. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; map&…
题意:有两个字符串,两个字符串中的相同字符可以相互匹配,\(?\)可以和任意字符匹配,输出最大匹配的字符数量和它们分别两个字符串中的位置. 题解:很容易贪心,我们先遍历第一个字符串,然后在第二个字符串中去找与当前位置相同的字符,这个过程我们可以先将每个字符的位置存下来然后再操作,遍历完后再遍历字符和问号,最后是问号和问号匹配,具体看代码吧,主要是想学习一下用队列来模拟操作(会方便很多). 代码: int n; string l,r; queue<int> h1[30],h2[30]; vect…
Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restores Permutation 题意: 有一个n的排列,但现在只给出相邻两位的差,问原排列是多少,如果不存在就输出-1. 题解: 通过相邻两位的差我们可以知道第一个元素和其它位置元素的大小关系,然后根据这个来搞一波就行了. 代码如下: #include <bits/stdc++.h> using n…
C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d      Java class name: (Any) Submit Status Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labele…
点击打开链接 Colored Sticks Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 27955   Accepted: 7403 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks…
Colored Sticks Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 28036   Accepted: 7428 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a st…
Colored Sticks Time Limit: 5000MS Memory Limit: 128000K Total Submissions: 32423 Accepted: 8556 Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straig…