QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#485329#9107. Zayin and Countpropane#RE 0ms0kbC++201.6kb2024-07-20 16:29:542024-07-20 16:29:54

Judging History

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

  • [2024-07-20 16:29:54]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-20 16:29:54]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
int a[70], len;

ULL f[11][70];
bool v[11][70];

ULL dfs(int state, int u, bool lim){
    if (u == 0) return 1;
    if (!lim and v[state][u]){
        return f[state][u];
    }
    v[state][u] = true;
    ULL ans = 0;
    int up = lim ? a[u] : 9;
    for(int i = 0; i <= up; i++){
        if (state >> i & 1){
            ans += dfs(state, u - 1, lim and (i == up));
        }
    }
    return f[state][u] = ans;
}

ULL get(int state, ULL x){
    int len = 0;
    while(x){
        a[++len] = x % 10;
        x /= 10;
    }
    return dfs(state, len, true);
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    memset(v, 0, sizeof v);
    int T;
    cin >> T;
    while(T--){
        int state1 = 0, state2 = 0;
        for(int i = 0; i < 10; i++){
            int x;
            cin >> x;
            state1 |= x << i;
        }
        for(int i = 0; i < 10; i++){
            int x;
            cin >> x;
            state2 |= x << i;
        }
        ULL x;
        cin >> x;
        LL cnt = get(state1, x);
        ULL l = 0, r = ULLONG_MAX;
        while(l < r){
            ULL mid = (__uint128_t(l) + r) / 2;
            if (get(state2, mid) >= cnt) r = mid;
            else l = mid + 1;
        }
        cout << r << '\n';
    }

}

详细

Test #1:

score: 0
Runtime Error

input:

10000
1 0 0 0 1 1 0 0 0 1
0 0 1 0 1 1 1 1 0 0
950595954440050004054505054050
1 0 0 0 1 1 1 1 0 0
1 1 1 0 1 0 0 0 1 1
45467007076660767550460064
1 1 1 1 0 0 0 1 0 0
1 1 0 1 1 0 1 0 0 1
23373171320213300170200722
0 0 0 0 1 1 1 0 1 0
0 0 1 0 0 1 0 1 1 1
558565664666565565558468668484
1 1 0 0 1 0 1 0 1 ...

output:


result: