UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214532#2377. 二进制N0669ms2176kbC++112.2kb2024-11-19 21:18:172024-11-19 23:02:40

answer

//
//  na 2377.cpp
//  Competitive Programming
//
//  Created by m2 on 2024/11/19.
//

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef __int128 lll;
typedef long long int ll;
typedef unsigned long long int ull;
const ull ullinf = 0xffffffffffffffff;
ll m;
int k;
vector<lll> kvs[4];
inline void init(){
    for(int i = 0; i <= 64; ++i)
        kvs[1].push_back(lll(1) << i);
    for(int i = 0; i <= 64; ++i)
        for(int j = 0; j < i; ++j)
            kvs[2].push_back((lll(1) << i) | (lll(1) << j));
    for(int i = 0; i <= 64; ++i)
        for(int j = 0; j < i; ++j)
            for(int k = 0; k < j; ++k)
                kvs[3].push_back((lll(1) << i) | (lll(1) << j) | (lll(1) << k));
}
#define ceilhalf(x) ((x >> 1) + (x & 1))
inline void smallk(){
    lll l, r;
    ull ans = 0;
    vector<lll> &vs = kvs[k];
//    cerr << "vs = " << endl;
//    for(int i = 0; i < 10; ++i)
//        cerr << "     " << ull(vs[i]) << endl;
    int len = int(vs.size());
    bool finmin = false;
    if(m <= len + 1){
        for(int i = int(m) - 1; i < len; ++i){
            r = vs[i - m + 1] - 1;
            l = ceilhalf(vs[i]);
            if(i != m - 1)
                l = max(l, vs[i - m]);
            if(i != len - 1)
                r = min(r, (vs[i + 1] >> 1) - (~vs[i + 1] & 1));
            else if(r > ullinf)
                r = ullinf;
            if(l <= r){
//                cerr << ull(l) << " -> " << ull(r) << endl;
//                cerr << "choosing " << ull(vs[i - m + 1]) << " -> " << ull(vs[i]) << endl;
                ans += r - l + 1;
                if(!finmin){
                    finmin = true;
                    cout << ull(l) << ' ';
                }
            }
        }
    }
    cout << ans << endl;
}
inline void smallm(){
    cout << "NVM TOO COMPLICATED" << endl;
}
inline void solve(){
    cin >> m >> k;
    if(k <= 3){
        smallk();
    }else if(m <= 10){
        smallm();
    }else{
        cout << "Passed" << endl;
    }
}
int main(){
    cin.tie(0)->sync_with_stdio(false);
    init();
    int t;
    cin >> t;
    while(t--)
        solve();
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Wrong Answer
time: 20ms
memory: 2172kb

input:

10000
1 1
1 1
2 1
1 1
1 1
1 1
6 1
4 1
1 1
5 1
3 1
1 1
3 1
1 1
1 1
3 1
5 1
4 1
1 1
4 1
5 1
1 1
3 1
3 ...

output:

1 18446744073709551615
1 18446744073709551615
0
1 18446744073709551615
1 18446744073709551615
1 1844...

result:

wrong answer 3rd lines differ - expected: '0 0', found: '0'

Test #2:

score: 0
Wrong Answer
time: 95ms
memory: 2172kb

input:

10000
42 2
58 2
1 1
64 2
1 1
29 2
3 1
46 2
1 1
62 2
33 2
1 1
46 2
1 1
1 2
52 2
52 2
1 1
6 1
5 1
4 1
...

output:

2199023255553 2199023255552
144115188075855873 144115188075855872
1 18446744073709551615
92233720368...

result:

wrong answer 7th lines differ - expected: '0 0', found: '0'

Test #3:

score: 0
Time Limit Exceeded

input:

10000
1 1
5 1
11 2
1967 3
314 3
1 1
2 1
3 2
1 1
482 3
1376 3
5 1
518 3
7 2
1264 3
5 1
1 1
43 2
688 3...

output:

1 18446744073709551615
0
1025 1024
9223372036854784001 8192
33562625 8192
1 18446744073709551615
0
5...

result:


Test #4:

score: 0
Time Limit Exceeded

input:

10000
6 2
67 2
4 1
3 1
10 2
1444 3
1730 3
1808 3
36 2
4 1
1489 3
18 2
1317 3
30 2
33 2
43 2
822 3
63...

output:

33 32
0
0
0
513 512
18014398509486081 4096
576460752303685633 262144
1152921642045800449 13743895347...

result:


Test #5:

score: 0
Wrong Answer
time: 50ms
memory: 2172kb

input:

10000
1 10
1 23
1 21
1 57
1 19
1 53
1 12
1 41
1 35
1 5
1 5
1 40
1 64
1 56
1 21
1 37
1 4
1 29
1 23
1 ...

output:

NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
...

result:

wrong answer 1st lines differ - expected: '512 256', found: 'NVM TOO COMPLICATED'

Test #6:

score: 0
Wrong Answer
time: 98ms
memory: 2176kb

input:

10000
3 30
1 58
8 31
3 8
7 34
1 52
4 37
5 55
1 51
1 57
3 16
10 9
5 12
7 5
9 34
3 12
6 30
8 47
1 19
9...

output:

NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
...

result:

wrong answer 1st lines differ - expected: '939524096 67108864', found: 'NVM TOO COMPLICATED'

Test #7:

score: 0
Wrong Answer
time: 91ms
memory: 2176kb

input:

10000
1 50
9 35
1 45
5 47
8 25
9 64
7 58
1 17
7 26
3 26
10 51
5 47
1 31
5 51
1 54
9 9
1 29
7 8
5 59
...

output:

NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
NVM TOO COMPLICATED
...

result:

wrong answer 1st lines differ - expected: '562949953421312 281474976710656', found: 'NVM TOO COMPLIC...

Test #8:

score: 0
Wrong Answer
time: 84ms
memory: 2176kb

input:

10000
96279085620 55
21919 62
1 1
410991310 58
128257342884936 16
32 2
1926983496109 53
273781151035...

output:

Passed
Passed
1 18446744073709551615
Passed
Passed
2147483649 2147483648
Passed
Passed
Passed
Passed...

result:

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

Test #9:

score: 0
Wrong Answer
time: 116ms
memory: 2176kb

input:

10000
609397314 58
83938839055331732 41
1929 3
106050747439191010 28
79727454070513347 25
2092718359...

output:

Passed
Passed
4611686155866341377 137438953472
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Pass...

result:

wrong answer 1st lines differ - expected: '18446743916937871359 32769', found: 'Passed'

Test #10:

score: 0
Wrong Answer
time: 115ms
memory: 2172kb

input:

10000
318262090679371113 39
11268952008014 52
488797365448018117 30
163471567770312245 41
1954343992...

output:

Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Passed
Pa...

result:

wrong answer 1st lines differ - expected: '12110134414455758655 17', found: 'Passed'