QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#766279#9745. 递增序列zxcdxwWA 34ms3748kbC++141.9kb2024-11-20 16:49:422024-11-20 16:49:43

Judging History

This is the latest submission verdict.

  • [2024-11-20 16:49:43]
  • Judged
  • Verdict: WA
  • Time: 34ms
  • Memory: 3748kb
  • [2024-11-20 16:49:42]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long
#define lowbit(x) (x)&(-x)
#define int long long
//#define double long double 
const int N = 1e6 + 5;
const ll base = 131;
const ll mod = 998244353;

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll>a(n + 1);
    vector<int>p(64, -1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i < n; ++i) {
        for (ll j = 63; j >= 0; --j) {
            int nowa = (1ll << j) & a[i], nowb = (1ll << j) & a[i + 1];
            if (p[j] != -1)nowa ^= p[j], nowb ^= p[j];
            if (nowa == nowb) continue;
            if (nowa) {
                if (p[j] != -1) {
                    cout << 0 << '\n';
                    return;
                }
                p[j] = 1;
                break;
            }
            else {
                if (p[j] != -1) {
                    continue;
                }
                p[j] = 0;
                break;
            }
        }
    }
    ll ans = 0;
    //assert(ans==1);
    //for(int i=0;i<64;++i) cerr<<p[i]<<" ";
    for (ll i = 63; i >= 0; --i) {
        if ((1ll << i) & k) {
            if (p[i] == 1) continue;
            ll cnt = 0;
            for (int j = i - 1; j >= 0; --j) {
                if (p[j] == -1) cnt++;
            }
            ans += (1ll << cnt);
            if (p[i] == 0) {
                cout << ans << '\n';
                return;
            }
            if (i == 0) ans++;
        }
        else if (p[i] == 1 && (1ll << i) > k) {
            cout << 0 << '\n';
            return;
        }
    }
    // bool ok=false;
    // for(int i=1;i<n;++i){
    //     if(a[i]<=a[i+1]) continue;
    //     else ok=true;
    // }
    cout << ans << '\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3396kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 34ms
memory: 3748kb

input:

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

output:

443794625192093522
0
432345564227567616
414708220571820990
716398192192370638
0
1949654914769744
0
0
0
811009189367843522
0
0
0
114457959388827198
0
0
0
91540211282631658
0
694703231769895640
144115188075855872
0
0
0
0
432345564227567616
65333152962117910
753346372609875092
0
0
364589864498708058
0
...

result:

wrong answer 1st lines differ - expected: '288230376151711744', found: '443794625192093522'