您当前的位置: 首页 > 

HeartFireY

暂无认证

  • 2浏览

    0关注

    334博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Codeforces Round #779 (Div. 2)

HeartFireY 发布时间:2022-03-28 16:30:47 ,浏览量:2

A. Marin and Photoshoot

既然要求相邻两人 1 1 1男 1 1 1女,那么对于 00 00 00中间暴力插 2 2 2个 1 1 1,对于 010 010 010中间暴力插 1 1 1个 1 1 1即可。

#include 
#define int long long
using namespace std;

inline void solve(){
    int n = 0; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    for(int i = 0; i  n;
    if(n & 1) cout  1] % MOD  
           
          
            a 
           
          
            [ 
           
          
            ( 
           
          
            p 
           
          
            o 
           
          
            s 
           
          
            + 
           
          
            i 
           
          
            − 
           
          
            2 
           
          
            ) 
           
          
            % 
           
          
            n 
           
          
            + 
           
          
            1 
           
          
            ] 
           
          
         
           a[(pos + i - 1) \% n + 1] - 1 > a[(pos + i - 2) \% n + 1] 
          
         
       a[(pos+i−1)%n+1]−1>a[(pos+i−2)%n+1]

#include 
#define int long long
using namespace std;

#define showYes cout  1) { showNo; return; }
    //for(int i = 1; i > t;
    while(t--) solve();
    return 0;
}
D1. 388535 (Easy Version)

给定区间 [ l , r ] [l,r] [l,r]和长度为 r − l + 1 r - l + 1 r−l+1的序列 c i {c_i} ci​,现在由该区间内所有数字生成一种排列,要求你找一个 x x x,使得原排列所有数字 x o r   x xor\ x xor x后得到的新排列恰好为序列 c i {c_i} ci​。

首先分析按位异或的影响:对某位而言:

  • 异或 1 1 1:对该位取反
  • 异或 0 0 0:保持该位不变

那么对于一段排列而言,我们对其异或上一个数 x x x后产生的影响为:

  • x x x的某位为 1 1 1:原始序列的所有数字该位 1 1 1和 0 0 0数量互反
  • x x x的某位为 0 0 0:原始学列的所有数字该位 1 1 1和 0 0 0数量保持不变

由于保证一定合法,那么,我们首先生成一个 [ 0 , r ] [0, r] [0,r]的序列,统计每位 1 1 1的数量,同时统计给定序列该位 1 1 1的数量,如果不相等,异或值 x x x的该位一定为 1 1 1。统计输出答案即可。

#include 
#define int long long
using namespace std;

inline void solve(){
    int bit1[20] = {0}, bit2[20] = {0};
    int l, r; cin >> l >> r;
    for(int i = 1, num; i > num;
        for(int j = 0; j             
关注
打赏
1662600635
查看更多评论
0.0429s