QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725652#9541. Expanding Arraythe_foolTL 0ms3856kbC++20973b2024-11-08 19:12:592024-11-08 19:12:59

Judging History

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

  • [2024-11-08 19:12:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3856kb
  • [2024-11-08 19:12:59]
  • 提交

answer

#include <bits/extc++.h>
using namespace std;


void solve() {
    int n;
    cin >> n;

    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    __gnu_pbds::gp_hash_table<int, bool> s;
    for (int i = 1; i <= n; i++) {
        s.insert({a[i], 1});
    }
    auto get = [&](int x, int y) {
        auto dfs = [&](auto &dfs, int cnt, int v) -> void {
            s.insert({v, 1});
            if (cnt == 3) return;
            dfs(dfs, cnt + 1, v & y);
            dfs(dfs, cnt + 1, v | y);
            dfs(dfs, cnt + 1, v ^ y);
        };
        dfs(dfs, 0, x);
    };

    for (int i = 1; i < n; i++) {
        get(a[i], a[i + 1]);
        get(a[i + 1], a[i]);
    }

    cout << s.size() << "\n";
}

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

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

/*
4
>>->>>
>>>->
>>>>>
>->>>>>>
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

2
3 5

output:

8

result:

ok single line: '8'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10
37760128 12721860 37519778 33518004 2760086 4473592 65451644 83416788 44877547 36766460

output:

56

result:

ok single line: '56'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

10
816913051 502168112 623785107 464692422 886370488 155984202 681252443 57479616 856353914 365166224

output:

56

result:

ok single line: '56'

Test #6:

score: -100
Time Limit Exceeded

input:

91141
991550420 630736630 613860632 683288307 801076961 655640638 825594849 292357587 386886324 280046446 969805344 558863217 285710238 677412106 663841817 331062932 665933557 860995134 10312018 472942826 92468113 114082647 184016662 952783745 869957199 427809351 730297077 324218702 340532370 865197...

output:


result: