QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755307#9541. Expanding ArrayzhishengWA 1ms3568kbC++231.9kb2024-11-16 17:00:132024-11-16 17:00:15

Judging History

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

  • [2024-11-16 17:00:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3568kb
  • [2024-11-16 17:00:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 rng(random_device{}());
int random(int l,int r) {
    return rng()%(r - l + 1) + l;
}
signed main() {
    ios::sync_with_stdio(0),cin.tie(0);
    auto solve = [&]() {
        int n;
        cin >> n;
        vector <vector <int>> v(n + 1);
        vector <int> a(n + 1);
        unordered_set <int> st;
        for(int i=1;i<=n;i++) {
            cin >> a[i];
        }
        for(int i=1;i<n;i++) {
            v[i].push_back(a[i]);
            v[i].push_back(a[i+1]);
        }
        for(int i=1;i<n;i++) {
            unordered_map<int,int> mp;
            for(auto x : v[i]) {
                mp[x] ++ ;
            }
            for(int j=1;j<=2000;j++) {
                int p = random(0,v[i].size()-2);
                int op = random(1,3);
                if(op==1) {
                    int val = (v[i][p]&v[i][p+1]);
                    if(!mp.count(val)) {
                        v[i].insert(v[i].begin() + p,val);
                        mp[val] ++ ;
                    }
                }
                else if(op==2) {
                    int val = (v[i][p]|v[i][p+1]);
                    if(!mp.count(val)) {
                        v[i].insert(v[i].begin() + p,val);
                        mp[val] ++ ;
                    }
                }
                else {
                    int val = (v[i][p]^v[i][p+1]);
                    if(!mp.count(val)) {
                        v[i].insert(v[i].begin() + p,val);
                        mp[val] ++ ;
                    }
                }
            }
        }
        for(int i=1;i<=n;i++) {
            for(auto x : v[i]) {
                // cout << x << " ";
                st.insert(x);
            }
        }
        cout << st.size() << "\n";
    };
    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

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

input:

2
3 5

output:

8

result:

ok single line: '8'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3560kb

input:

10
37760128 12721860 37519778 33518004 2760086 4473592 65451644 83416788 44877547 36766460

output:

54

result:

wrong answer 1st lines differ - expected: '56', found: '54'