QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796963 | #9745. 递增序列 | JEdward | WA | 0ms | 3688kb | C++20 | 2.1kb | 2024-12-02 13:02:21 | 2024-12-02 13:02:22 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define endl '\n'
#define lowbit(x) (x & -x)
#define all(s) s.begin(), s.end()
#define pii pair<int,int>
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define here system("pause")
using namespace std;
template <class T>
inline void read(T &x){
x = 0;
char c = getchar();
bool f = 0;
for (; !isdigit(c); c = getchar()) f ^= (c == '-');
for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
x = f ? -x : x;
}
template <class T>
inline void write(T x){
if (x < 0) putchar('-'), x = -x;
if (x < 10) putchar(x + 48);
else write(x / 10), putchar(x % 10 + 48);
}
template<typename T> void chkmin(T& lhs, const T& rhs) { lhs = lhs > rhs ? rhs : lhs; }
template<typename T> void chkmax(T& lhs, const T& rhs) { lhs = lhs < rhs ? rhs : lhs; }
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int INF = 8e18 + 9;
const double eps = 1e-9;
const double Pi = acos(-1);
inline int pow(int a, int b, int p){ int res = 1%p; while(b){ if(b&1) res=res*a%p; a=a*a%p, b>>=1;} return res;}
inline int inv(int a, int p){ return pow(a,p-2,p)%p;}
mt19937 rnd(chrono::duration_cast<chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
int randint(int L, int R) {
uniform_int_distribution<int> dist(L, R);
return dist(rnd);
}
inline void sol(){
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int &i : a) cin >> i;
int x = 0, y = 0;
for(int i=1;i<n;i++){
if(a[i] != a[i - 1]){
int t = __lg(a[i] ^ a[i - 1]);
if(a[i] >> t & 1)
y |= 1ll << t;
else
x |= 1ll << t;
}
}
k -= x;
if((x & y) || k < 0) return cout << 0 << endl, void();
int ans = 0;
x = ~(x | y);
int u = k & ~x;
if(u){
int t = __lg(u);
k |= (1ll << t) - 1;
k &= x;
}
for(int i=61;i>=0;i--){
if(x >> i & 1){
ans = ans * 2;
ans += k >> i & 1;
}
}
cout << ans + 1 << endl;
}
signed main(){
IOS;
int tc = 1;
// cin >> tc;
while(tc--){
sol();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3688kb
input:
1 4 17 3 2 5 16
output:
5
result:
wrong answer 1st lines differ - expected: '4', found: '5'