CCPC2018-湖南全国邀请赛-重现赛(填坑中)

E - String Transformation HDU - 6282 

题意:

说有两个字符串S,T,以及规则:可以通过插入或删除子字符串"aa","bb"和"abab"来转换字符串,即对于字符串 A∘ ∘ v ,A 可以变换为 A = u  v,反过来也可以。问最后能否将 S 变换为 T 

题解:

由于没有字符C的替换规则,所以可以确定C的数量不相等的话一定不能够使得S==T,再者,如果任意两个C之间,以及C和边界之间 a 的数量以及b的数量不同时为奇偶的时候也不能使得S=T,√

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#pragma GCC optimize(2)
using namespace std;
const int inf=0x3f3f3f3f;
#define ll long long
const int mod = 1e9+7;/// 998244353;
const int mxn = 8e4 +7;
const int N = 8e4 + 7 ;
ll _ , n , m , t , k , ans , cnt ;
template 
void rd(T &x){
    T flag = 1 ; x = 0 ; char ch ;
    ch = getchar();
    while(!isdigit(ch)) { if(ch=='-') flag = -1; ch = getchar(); }
    while(isdigit(ch)) { x = (x<<1) + (x<<3) + (x^48); ch = getchar(); }
    x*=flag;
}
void solve()
{
    string s1 ,s2 ;
    while(cin>>s1>>s2){
        int n1 = count(s1.begin(),s1.end(),'c');
        int n2 = count(s2.begin(),s2.end(),'c');
        if(n1!=n2){
            cout<<"No"< 
    
View Code

 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#pragma GCC optimize(2)
using namespace std;
const int inf=0x3f3f3f3f;
#define ll long long
const int mod = 1e9+7;/// 998244353;
const int mxn = 8e4 +7;
const int N = 8e4 + 7 ;
ll _ , n , m , t , k , ans , cnt ;
template 
void rd(T &x){
    T flag = 1 ; x = 0 ; char ch ;
    ch = getchar();
    while(!isdigit(ch)) { if(ch=='-') flag = -1; ch = getchar(); }
    while(isdigit(ch)) { x = (x<<1) + (x<<3) + (x^48); ch = getchar(); }
    x*=flag;
}
vector calc(string s1)
{
    vector v;
    int ans = 0 ;
    for(int i=0;i<=s1.size();i++)
        if(i==s1.size() || s1[i]=='c')
            v.push_back(ans) , ans = 0 ;
        else ans^=s1[i];
    return v;
}
void solve()
{
    string s1 ,s2 ;
    while(cin>>s1>>s2){
        if(calc(s1) == calc(s2)) cout<<"Yes\n";
        else cout<<"No\n";
    }
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
    solve();
}
位运算

 

K-2018 HDU - 6286 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#pragma GCC optimize(2)
using namespace std;
const int inf=0x3f3f3f3f;
#define ll long long
const int mod = 1e9+7;/// 998244353;
const int mxn = 8e4 +7;
const int N = 8e4 + 7 ;
ll _ , n , m , t , k , ans , cnt ;
template 
void rd(T &x){
    T flag = 1 ; x = 0 ; char ch ;
    ch = getchar();
    while(!isdigit(ch)) { if(ch=='-') flag = -1; ch = getchar(); }
    while(isdigit(ch)) { x = (x<<1) + (x<<3) + (x^48); ch = getchar(); }
    x*=flag;
}
void solve()
{
    ll l,r,L,R;
    while(cin>>l>>r>>L>>R){
        ll l2018 = r/2018 - (l-1)/2018 ;
        ll l1009 = r/1009 - (l-1)/1009 - l2018;
        ll l2 = r/2 - (l-1)/2 - l2018 ;

        ll L2018 = R/2018 - (L-1)/2018 ;
        ll L1009 = R/1009 - (L-1)/1009 - L2018 ;
        ll L2 = R/2 - (L-1)/2 - L2018 ;
        cout<<(r-l+1)*L2018 + (R-L+1)*l2018 + l2*L1009 + L2*l1009 - l2018*L2018 < 
    
View Code

 

你可能感兴趣的:(CCPC2018-湖南全国邀请赛-重现赛(填坑中))