牛客网暑期ACM多校训练营(第十场)

传送

A题。签到

#include 
#define repu(i,s,e) for(int i = s;i <= e; ++i)
#define repd(i,s,e) for(int i = s;i >= e; --i)
#define pb push_back
#define emb emplace_back
#define mst(arr, v) memset(arr, v, sizeof(arr))
#define close_ios ios::sync_with_stdio(false)
#define close_cin cin.tie(0)
#define close_cout cout.tie(0)
#define ct(a) cout<>T;while(T--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair Pa;
typedef vector Ve;
const double PI = acos(1.0);
const double eps = 1e-8;
int dir[4][2] = {{0,1},{0,-1},{-1,0},{1,0}};
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 5;
const int M = 100 + 5;
const int mod = 998244353;
ll n, m;
ll a[N];
int lowbit(int k)
{
    return k & -k;
}
ll sum(int p)
{
    ll r = 0;
    while(p > 0)
    {
        r += a[p];
        p -= lowbit(p);
    }
    return r;
}

void add(int p, ll v)
{
    while(p <= n)
    {
        a[p] += v;
        p += lowbit(p);
    }
}

ll quickPow(ll a, ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b&1)
            res = res * a % mod;

        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int main()
{
    Repeat
    {
        mst(a,0);
        ll t;

        scanf("%lld%lld",&n,&m);

        repu(i,1,n)
            scanf("%lld",&t), add(i,t);

        ll tmp = quickPow(2, n*m);

        int op, l, r;
        repu(i,1,m)
        {
            ll w;

            sf3(op,l,r);

            if(op == 1)
                continue;

            w = (sum(r) - sum(l-1)) % mod * tmp % mod;

            ct(w);
        }
    }
    return 0;
}

J题 直接暴力就行

#include
#include
using namespace std;
 
int main(){
    int t;
    string s,s1;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        cin>>s;
        for(int i = 1; i < n ; ++i){
            cin>>s1;
            int j,k;
            for(j = 0,k=0; j

 

你可能感兴趣的:(牛客网,ACM)