提出 #41358860


ソースコード 拡げる

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define test int T; cin >> T; while(T--)
using namespace std;
using lnt = long long;

int main(){
    cin.tie(nullptr), ios::sync_with_stdio(false);

    string s;
    lnt n;
    lnt ans = 0;
    cin >> s >> n;
    int l = s.length();
    for(int i=0; i<l; i++){
        if(s[i] == '1') ans += 1LL << (l-1-i);
    }
    if(ans > n){
        cout << -1;
        return 0;
    }
    for(int i=0; i<l; i++){
        if(s[i] != '?') continue;
        if(ans + (1LL << (l-1-i)) <= n) ans += 1LL << (l-1-i);
    }
    cout << ans;
}

提出情報

提出日時
問題 D - Bitmask
ユーザ pluie
言語 C++ (GCC 9.2.1)
得点 400
コード長 617 Byte
結果 AC
実行時間 6 ms
メモリ 3572 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 46
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random1_00.txt, 01_random1_01.txt, 01_random1_02.txt, 01_random1_03.txt, 01_random1_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 03_random3_06.txt, 03_random3_07.txt, 04_random4_00.txt, 04_random4_01.txt, 04_random4_02.txt, 04_random4_03.txt, 04_random4_04.txt, 04_random4_05.txt, 04_random4_06.txt, 04_random4_07.txt, 05_random5_00.txt, 05_random5_01.txt, 05_random5_02.txt, 05_random5_03.txt, 05_random5_04.txt, 05_random5_05.txt, 05_random5_06.txt, 05_random5_07.txt, 06_handmade_00.txt, 06_handmade_01.txt, 06_handmade_02.txt, 06_handmade_03.txt, 06_handmade_04.txt, 06_handmade_05.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 6 ms 3472 KiB
00_sample_01.txt AC 2 ms 3568 KiB
00_sample_02.txt AC 2 ms 3412 KiB
01_random1_00.txt AC 2 ms 3484 KiB
01_random1_01.txt AC 2 ms 3548 KiB
01_random1_02.txt AC 2 ms 3456 KiB
01_random1_03.txt AC 2 ms 3416 KiB
01_random1_04.txt AC 2 ms 3472 KiB
02_random2_00.txt AC 4 ms 3564 KiB
02_random2_01.txt AC 2 ms 3416 KiB
02_random2_02.txt AC 2 ms 3472 KiB
02_random2_03.txt AC 2 ms 3472 KiB
02_random2_04.txt AC 2 ms 3568 KiB
02_random2_05.txt AC 2 ms 3520 KiB
02_random2_06.txt AC 2 ms 3408 KiB
02_random2_07.txt AC 2 ms 3416 KiB
03_random3_00.txt AC 2 ms 3468 KiB
03_random3_01.txt AC 2 ms 3560 KiB
03_random3_02.txt AC 2 ms 3412 KiB
03_random3_03.txt AC 2 ms 3572 KiB
03_random3_04.txt AC 2 ms 3416 KiB
03_random3_05.txt AC 2 ms 3568 KiB
03_random3_06.txt AC 2 ms 3484 KiB
03_random3_07.txt AC 2 ms 3468 KiB
04_random4_00.txt AC 2 ms 3408 KiB
04_random4_01.txt AC 2 ms 3544 KiB
04_random4_02.txt AC 2 ms 3528 KiB
04_random4_03.txt AC 2 ms 3544 KiB
04_random4_04.txt AC 1 ms 3472 KiB
04_random4_05.txt AC 2 ms 3412 KiB
04_random4_06.txt AC 2 ms 3572 KiB
04_random4_07.txt AC 2 ms 3564 KiB
05_random5_00.txt AC 2 ms 3416 KiB
05_random5_01.txt AC 1 ms 3488 KiB
05_random5_02.txt AC 2 ms 3472 KiB
05_random5_03.txt AC 2 ms 3544 KiB
05_random5_04.txt AC 2 ms 3472 KiB
05_random5_05.txt AC 2 ms 3416 KiB
05_random5_06.txt AC 2 ms 3564 KiB
05_random5_07.txt AC 2 ms 3488 KiB
06_handmade_00.txt AC 5 ms 3484 KiB
06_handmade_01.txt AC 2 ms 3484 KiB
06_handmade_02.txt AC 2 ms 3408 KiB
06_handmade_03.txt AC 2 ms 3468 KiB
06_handmade_04.txt AC 1 ms 3500 KiB
06_handmade_05.txt AC 2 ms 3568 KiB