QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775302#9745. 递增序列bluejellyfishWA 0ms3596kbC++231.5kb2024-11-23 15:24:112024-11-23 15:24:11

Judging History

This is the latest submission verdict.

  • [2024-11-23 15:24:11]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3596kb
  • [2024-11-23 15:24:11]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf = numeric_limits<int>::max();
const int S = 64;

void miss() {
    int n, k; cin >> n >> k;
    vector<int> a(n + 1) , b(S , -1); 
    for(int i = 1 ; i <= n ; i ++) cin >> a[i];
    auto check = [&](int x , int y) -> bool {
        for(int i = 62 ; ~i ; i --) if((x >> i & 1) != (y >> i & 1)) {
            int ok = 1;
            if((x >> i & 1) < (y >> i & 1)) ok = 0;
            if(b[i] == (ok ^ 1)) return false;
            else b[i] = ok;
            return true;
        }
        return true;
    };

    for(int i = 1 ; i < n ; i ++) if(!check(a[i],a[i + 1])) {
        return cout << "0\n" , void();
    }
	for(int i = 0; i <= 63; i++) {
		if(b[i] != -1) cout << i << endl;
	}
    vector<int> dp(S , -1);
    auto dfs = [&](auto self , int pos , int limit) -> int{
        if(!~pos) return 1;
        if(!limit && dp[pos] != -1) return dp[pos];
        int up = 1 , now = k >> pos & 1;
        if(limit && !now) up = 0;
        int ans = 0;
        if(b[pos] == -1) for(int i = 0 ; i <= up ; i ++) ans += self(self,pos - 1,limit&(now == i));
        else if(b[pos] <= up) ans += self(self,pos - 1,limit&(now == b[pos]));
        if(!limit) dp[pos] = ans;
        return ans;
    };
    cout << dfs(dfs,62,1) << "\n";
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    cin >> T;
    while(T--) miss();
	//system("pause");
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3596kb

input:

1
4 17
3 2 5 16

output:

0
2
4
4

result:

wrong answer 1st lines differ - expected: '4', found: '0'