QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783498#9745. 递增序列GodwangWA 119ms3704kbC++237.6kb2024-11-26 10:13:572024-11-26 10:14:03

Judging History

你现在查看的是最新测评结果

  • [2024-11-26 10:14:03]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:3704kb
  • [2024-11-26 10:13:57]
  • 提交

answer

#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#include <random>
#include<list> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define lowbit(x) ((x)&(-x))
ll extend_gcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extend_gcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
ll fastpow(ll a, ll n, ll mod)
{
    ll ans = 1;
    a %= mod;
    while (n)
    {
        if (n & 1)
            ans = (ans * a) % mod; //% mod
        a = (a * a) % mod;         //% mod
        n >>= 1;
    }
    return ans;
}

inline void write(__int128 x)
{
    if (x > 9)
    {
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
__int128 sqrt(__int128 m)
{
    __int128 leftt = 0, rightt = ((__int128)1) << 51, ret = -1, mid;
    while (leftt < rightt)
    {
        mid = (leftt + rightt) / 2;
        if (mid * mid > m)
        {
            rightt = mid;
        }    
        else
        {
            leftt = mid + 1;
            ret = mid;
        }
    }
    return ret;
}

const double eps = 1e-6;
int sgn(double x)
{
    if(fabs(x)<eps)
    {
        return 0;
    }
    else return x<0?-1:1;
}

struct Point
{
    double x,y;
    Point()
    {

    }
    Point(double x,double y):x(x),y(y)
    {

    }
    Point operator + (Point B)
    {
        return Point(x+B.x,y+B.y);
    }
    Point operator - (Point B)
    {
        return Point(x-B.x,y-B.y);
    }
    bool operator == (Point B)
    {
        return sgn(x-B.x)==0&&sgn(y-B.y)==0;
    }
    bool operator < (Point B)
    {
        return sgn(x-B.x)<0||(sgn(x-B.x)==0&&sgn(y-B.y)<0);
    }
};
typedef Point Vector;
double Cross(Vector A,Vector B)//叉积
{
    return A.x*B.y-A.y*B.x;
}
double Distance(Point A,Point B)
{
    return hypot(A.x-B.x,A.y-B.y);
}
int Convex_hull(Point *p,int n,Point *ch)
{
    n=unique(p,p+n)-p;
    sort(p,p+n);
    int v=0;

    for(int i=0;i<n;i++)
    {
        while (v>1&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0)
        {
            v--;
        }
        ch[v++]=p[i];
    }

    int j=v;

    for(int i=n-2;i>=0;i--)
    {
        while (v>j&&sgn(Cross(ch[v-1]-ch[v-2],p[i]-ch[v-1]))<=0)
        {
            v--;
        }
        ch[v++]=p[i];
    }
    if(n>1)
    {
        v--;
    }
    return v;
}

int kmp(string s, string p)
{
    int ans = 0, lastt = -1;
    int lenp = p.size();
    vector<int > Next(lenp+3,0);
    rep(i, 1, lenp - 1)
    {
        int j = Next[i];
        while (j && p[j] != p[i])
        {
            j = Next[j];
        }
        if (p[j] == p[i])
        {
            Next[i + 1] = j + 1;
        }
        else
        {
            Next[i + 1] = 0;
        }
    }
    int lens = s.size();
    int j = 0;
    rep(i, 0, lens - 1)
    {
        while (j && s[i] != p[j])
        {
            j = Next[j];
        }
        if (s[i] == p[j])
        {
            j++;
        }
        if (j == lenp)
        {
            ans++;
        }
    }
    return ans;
}

int dir[4][2] =
    {
        {-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // 左右上下
// int dir[8][2]={
//         {-1, 0}, {0, 1}, {1, 0}, {0, -1},{-1,-1},{-1,1},{1,-1},{1,1}
// };

#define endl '\n'//交互题请删除本行
const ll inf = 1000000000000000000ll;
const ll mod1 = 998244353ll, P1 = 131, mod2 = 1e9 + 7ll, P2 = 13331;
ll inverse(ll x)
{
    return fastpow(x,mod1-2,mod1);
}

const int N = 2e5 + 10, M = 69 + 10;

///////////////////////////////////

int tt;

int n;
ll k;

ll a[N];

ll bian[M];


///////////////////////////////////

bool check(int id)
{
    rep(i,id,62)
    {
        if( (k&(1ll<<i))==0&& bian[i]==1    )
        {
            return 0;
        }
        if( (k&(1ll<<i))&& bian[i]==-1    )
        {
            return 0;
        }
    }
    return 1;
}

///////////////////////////////////

void init()
{
    fill(bian+0,bian+62+1,0);
}

///////////////////////////////////

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);//交互题请删除本行
   // freopen("ain.txt", "r", stdin); freopen("aout.txt", "w", stdout);

    cin>>tt;
    rep(ttt,1,tt)
    {
        init();
        cin>>n>>k;
        // if(tt==36360&&ttt==17)
        // {
        //     cout<<n<<" "<<k<<endl;
        // }
        
        rep(i,1,n)
        {
            cin>>a[i];
            // if(tt==36360&&ttt==17)
            // {
            //     cout<<a[i]<<" ";
            // }
        }

        bool flag=1;
        rep(i,1,n-1)
        {
           

            per(j,0,62)
            {
                if((a[i] &(1ll<<j)   )&&(a[i+1]&(1ll<<j)  )==0  )
                {
                    if(bian[j]==-1)
                    {
                        flag=0;
                    }
                    bian[j]=1;
                    break;
                }

                if((a[i] &(1ll<<j)   )==0&&(a[i+1]&(1ll<<j)  ))
                {
                    if(bian[j]==1)
                    {
                        flag=0;
                    }
                    bian[j]=-1;
                    break;
                }
            }
        }
        if(flag==0)
        {
            cout<<0<<endl;
            continue;
        }

        ll ans=0;

        per(i,0,62)
        {
            if(check(i+1)==0)
            {
                break;
            }

            if(k&(1ll<<i))
            {
                if(bian[i]==1)
                {
                    continue;
                }
                ll add=0;
                rep(j,0,i-1)
                {
                    if(bian[j]==0)
                    {
                        add++;
                    }
                }
                add=(1ll<<add);
                ans+=add;

            }
            else//is 0
            {

            }
        }

        rep(i,1,n)
        {
            a[i]^=k;
        }

        rep(i,2,n)
        {
            if(a[i-1]>=a[i])
            {
                flag=0;
                break;
            }
        }
       // cout<<flag<<endl;
        if(flag)
        {
            ans++;
        }
        // if(tt!=36360)
        // {
            cout<<ans<<endl;
        // }
        // rep(i,1,n)
        // {
        //     a[i]^=k;
        // }

        
        // ll anss=0;
        // rep(i,0,k)
        // {
        //     rep(j,1,n)
        //     {
        //         a[j]^=i;
        //     }

        //     bool flag=1;
        //     rep(j,1,n-1)
        //     {
        //         if(a[j]>=a[j+1])
        //         {
        //             flag=0;
        //             break;
        //         }
        //     }

        //     rep(j,1,n)
        //     {
        //         a[j]^=i;
        //     }

        //     if(flag)
        //     {
        //         anss++;
        //     }
        // }
        // cout<<anss<<endl;

    }
    
    


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3632kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 67ms
memory: 3632kb

input:

36156
2 732025001343805266
563399128172323734 55283226774627822
7 388099190813067712
564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124
2 798714574862593347
426890163990834364 434764725667883272
1 414708220571820990
42...

output:

288230376151711744
0
432345564227567616
414708220571820991
716398192192370638
0
1949654914769744
0
0
0
811009189367843523
0
0
0
114457959388827198
36028797018963968
0
0
91540211282631659
0
694703231769895640
144115188075855872
0
0
0
0
432345564227567616
65333152962117911
753346372609875093
180143985...

result:

ok 36156 lines

Test #3:

score: 0
Accepted
time: 119ms
memory: 3572kb

input:

66700
5 574806949
707283080 678928379 541095440 909663418 934562284
2 131740903
1072092807 29505236
1 288553982
996051310
3 327852411
555539857 562077878 310330495
5 43708614
467258834 418367471 258444521 166976259 1064316226
4 128498668
513637339 62151118 158694610 650278927
2 351983999
4118288 333...

output:

33554432
0
288553983
0
0
0
268435456
0
149009740
386781916
437566564
385875968
0
315141961
271302559
33554432
0
0
0
95224229
129359372
134217728
134217728
268435456
0
67108864
33554432
0
0
0
268435456
0
0
134217728
67108864
268435456
212106049
67108864
0
268435456
4450845
268435456
0
67108864
378512...

result:

ok 66700 lines

Test #4:

score: -100
Wrong Answer
time: 70ms
memory: 3704kb

input:

36360
1 96
43
4 13
34 87 65 66
10 19
30 15 3 46 37 35 84 82 83 74
9 4
52 54 49 62 46 31 8 85 85
5 11
47 60 16 125 73
2 82
41 86
6 53
96 106 117 88 37 54
4 88
25 85 70 116
6 77
2 7 10 15 83 79
4 93
41 35 10 121
3 54
39 49 73
8 14
10 1 18 59 62 61 66 89
9 66
58 39 26 17 122 117 107 97 98
9 95
29 23 0 ...

output:

97
0
0
0
0
64
0
16
8
16
32
2
4
4
0
0
5
15
79
31
2
0
64
4
4
0
4
6
4
2
0
8
9
8
0
8
0
4
30
0
2
4
4
24
2
4
4
0
2
48
4
2
0
4
13
0
0
32
47
8
0
2
0
21
8
0
0
0
0
4
42
0
16
0
1
64
8
22
16
4
4
32
16
0
0
0
8
0
14
42
29
0
16
8
0
0
0
8
28
71
0
33
16
8
6
4
4
28
0
0
32
4
8
32
82
0
0
0
0
85
16
0
16
19
32
1
4
32
0
1...

result:

wrong answer 17th lines differ - expected: '6', found: '5'