codeforce 1278A(暴力水题)
生活随笔
收集整理的這篇文章主要介紹了
codeforce 1278A(暴力水题)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
傳送門
題意:給出字符串s和h,將s任意排序,是否使得s為p的子字符串. 數據水,可以直接暴力。 #include <set> #include <map> #include <cmath> #include <stack> #include <queue> #include <string> #include <vector> #include<cstring> #include <stdio.h> #include <iostream> #include <algorithm> #define INF 0x3f3f3f3f using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn = 1e3+5; int n; char s[maxn],h[maxn]; int main() {cin>>n;while (n--){cin>>s>>h;int len=strlen(s),l=strlen(h);if(len>l){printf("NO\n");continue;}string p=(string)s;bool flag=false;int cou=0;bool f=false;for(int i=0;i<l;i++) {for (int pos = i; pos<i+len; pos++) {for (int j = 0; j < len; j++) {if (p[j] == 'A')continue;if (h[pos] == (char) p[j]) {p[j] = 'A';flag = true;cou++;break;}}if (cou == len){f=true;break;}if (!flag){p = (string) s, cou = 0;break;}flag = false;}if(f)break;}if(f)printf("YES\n");elseprintf("NO\n");} }總結
以上是生活随笔為你收集整理的codeforce 1278A(暴力水题)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Make defensive copie
- 下一篇: autofac实战