Codeforces Round #550 (Div. 3)E. Median String

难受啊///网卡的交不了题…多15分钟就能A了啊
还是太菜了……

扔一下垃圾代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define ll long long
#define lowbit(x) (x&(-x))
#define PI acos(-1)
#define ms(x,y) memset(x, y, sizeof(x))
using namespace std;

const int maxn = 2e5+7;
char a[maxn], b[maxn];

int ans[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    scanf("%s%s", a, b);
    
    for(int i=n-1;i>=0;i--)
    {
        int ta = a[i] - 'a';
        int tb = b[i] - 'a';
        ans[i] = ta + tb;
        
        if(ans[i]&1)
        {
            ans[i+1] += 13;
            ans[i] = (ans[i] - 1) / 2;
            ans[i] += ans[i+1] / 26;
            ans[i+1] %= 26;
        }
        else ans[i] = ans[i] / 2;
    }
    

    
    for(int i=0;i<n;i++) printf("%c", 'a' + ans[i]); puts("");
}

  

猜你喜欢

转载自www.cnblogs.com/HazelNut/p/10634221.html