QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748082#9426. Relearn through Reviewxzin#WA 406ms5648kbC++141.1kb2024-11-14 19:16:382024-11-14 19:16:38

Judging History

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

  • [2024-11-14 19:16:38]
  • 评测
  • 测评结果:WA
  • 用时:406ms
  • 内存:5648kb
  • [2024-11-14 19:16:38]
  • 提交

answer

#include <bits/stdc++.h>


#define N 301000
#define ll long long
using namespace std;

struct bala {
    set<ll> v1;
    set<ll> v2;
    void init() {
        v1.clear();
        v2.clear();
    }
    void v1_insert(ll c) {
        v1.insert(c);
    }
    void v2_insert(ll c) {
        v2.insert(c);
    }
}la[2];
ll a[N], n, k, ans, b[N];
void sl() {
    cin>>n>>k; b[n + 1] = 0;
    for(int i = 1;i <= n; i++) cin>>a[i]; 
    for(int i = n;i >= 1; i--) b[i] = __gcd(b[i + 1], a[i]);
    ans = b[1];
    la[1].v1_insert(a[1]);
    la[1].v2_insert(a[1] + k);
    for(int i = 2;i <= n; i++) {
        int e = i % 2, o = (i - 1) % 2;
        
        la[e].init();
        for(auto it : la[o].v1) {
            la[e].v1_insert(__gcd(it, a[i]));
            la[e].v2_insert(__gcd(it, a[i] + k));
        }
        for(auto it : la[o].v2) {
            la[e].v2_insert(__gcd(it, a[i] + k));
            ans = max(ans, __gcd(it, b[i]));
        } 
    }
    for(auto it : la[n % 2].v2) {
        ans = max(ans, it);
    }
    cout<<ans<<endl;
}
int main() {
    int T; cin>>T;
    while (T--) {
        sl();
    }
    
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5648kb

input:

2
6 2
5 3 13 8 10 555
3 0
3 6 9

output:

5
3

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 406ms
memory: 5632kb

input:

100000
1 608611451460421713
33155506392034032
1 743116173559300609
6138108577573005
7 364454564010802125
657035115675878115 657035115675878115 657035115675878115 657035115675878115 657035115675878115 292580551665075990 657035115675878115
4 316648374341335221
365788422120542814 182894211060271407 731...

output:

641766957852455745
749254282136873614
657035115675878115
182894211060271407
880411769063535667
1315487819536857453
183698346865682381
962990836390050009
962990836390050009
878097339332572161
1592123683159826250
997057718507559252
1592123683159826250
37337367838628559
632093288650732211
3771217139073...

result:

wrong answer 6th lines differ - expected: '560553564512176618', found: '1315487819536857453'