标签:stream ring col cstring sse long cas return turn
题意:一个串变为另一个串要移动的次数。
串中相对位置相同的移过去就行。
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <iomanip> #include <cstring> #include <map> #include <queue> #include <set> #include <cassert> #define mkp make_pair using namespace std; const double EPS=1e-8; const int SZ=5010,INF=0x7FFFFFFF; typedef long long lon; int main() { std::ios::sync_with_stdio(0); //freopen("d:\\1.txt","r",stdin); lon casenum; //cin>>casenum; //for(lon time=1;time<=casenum;++time) { string str1,str2; cin>>str1>>str2; vector<int> arr,dst; for(int i=0;i<str1.size();++i)if(str1[i]==‘+‘)arr.push_back(i); for(int i=0;i<str2.size();++i)if(str2[i]==‘+‘)dst.push_back(i); if(arr.size()!=dst.size())cout<<-1<<endl; else { int res=0; for(int i=0;i<arr.size();++i) { res+=abs(arr[i]-dst[i]); } cout<<res<<endl; } } return 0; }
标签:stream ring col cstring sse long cas return turn
原文地址:https://www.cnblogs.com/gaudar/p/9789263.html