1. 程式人生 > >UVa 10340 - All in All 水題 難度: 0

UVa 10340 - All in All 水題 難度: 0

php problem sse col ++ div cst cassert pair

題目

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1281


題意

問字符串a能否是字符串b的子序列

思路

明顯,計數對的上就行

感想

因為忘了break錯了一次

代碼

技術分享圖片
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include 
<cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #define LOCAL_DEBUG using namespace std; typedef pair<int, int> MyPair; int main() { #ifdef LOCAL_DEBUG freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt
", "r", stdin); //freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout); #endif // LOCAL_DEBUG int T; string a, b; for (int ti = 1;cin>>a>>b; ti++) { int sza = 0, szb = 0; for (sza = 0, szb = 0; sza < a.size() && szb < b.size(); sza++, szb++) {
while (szb < b.size() && a[sza] != b[szb]) { szb++; } if (szb >= b.size())break; } if (sza == a.size())puts("Yes"); else puts("No"); } return 0; }
View Code

UVa 10340 - All in All 水題 難度: 0