d-编程思维

D - Match or Not

https://atcoder.jp/contests/abc287/tasks/abc287_d

 

思路

https://www.acwing.com/solution/content/166180/

对于t,分成两个段,

前段在s和t的最大前缀找,

后端在s和t的最大后缀找。

Code

https://atcoder.jp/contests/abc287/submissions/38576945

string s, t;
 
int main()
{
    cin >> s;
    cin >> t;
 
    int slen = s.size();
    int tlen = t.size();
    
    int prefixlen = 0;
    for(int i=0; i<tlen; i++){
        char si = s[i];
        char ti = t[i];
        
        if (si == ti
            || si == '?'
            || ti == '?'){
            prefixlen++;
        } else {
            break;
        }
    }
 
    int suffixlen = 0;
    for(int i=0; i<tlen; i++){
        char si = s[slen-i-1];
        char ti = t[tlen-i-1];
 
        if (si == ti
            || si == '?'
            || ti == '?') {
            suffixlen++;
        } else {
            break;
        }
    }
 
    for(int x=0; x<=tlen; x++){
        if(x<=prefixlen
            && tlen-x<=suffixlen){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
 
    return 0;
}
 

 

版权声明:本文版权归作者所有,遵循 CC 4.0 BY-SA 许可协议, 转载请注明原文链接
https://www.cnblogs.com/lightsong/p/17091239.html

c-编程思维

C - Don’t be cycle https://atcoder.jp/contests/abc288/tasks/abc288_c   思路 检测出最小环有几个, 然后破掉相同数目的边即可。     检测最小环数目方法:   Code https://atcoder.jp/contests/abc288/su

d-编程思维

D - Restricted Permutation https://atcoder.jp/contests/abc223/tasks/abc223_d   思路 https://zhuanlan.zhihu.com/p/135094687 利用拓扑排序方法, 先找入度为0的点,建立优先队列,包括: 2 和 3 从2

d-编程思维

D - Takahashi Tour https://atcoder.jp/contests/abc213/tasks/abc213_d   思路 图数据结构存储边的关系。 DFS遍历, 对于相邻节点存储使用set。 Code https://atcoder.jp/contests/abc213/submissions

d-编程思维

D - Pair of Balls https://atcoder.jp/contests/abc216/tasks/abc216_d   思路 m个桶, n个颜色, 第一轮遍历所有桶的最上面球的颜色, 将相同颜色的球所在队列, 计入 color节点, 即是说,存在两个桶的最上面的两个球颜色相同, 例如 a11 和 a

d-编程思维

D - Step Up Robot https://atcoder.jp/contests/abc289/tasks/abc289_d   思路 - 1 DFS 从0开始, 否则运用所有可能步子,检查新的位置点, 遇到block返回false, 是目标点x返回true Code - 1 DFS https://atc

c-编程思维

C - Coverage https://atcoder.jp/contests/abc289/tasks/abc289_c   思路 对所有组合,依此遍历 判断组合内所有的集合是否覆盖 1...n 判断过程中,如果发现某个数不能被覆盖,则说明此组合不满足要求, 如果满足要求,计数加1 Code https://at