QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#367361#6753. MediansmiletWA 0ms5612kbC++201.8kb2024-03-25 21:38:312024-03-25 21:38:31

Judging History

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

  • [2024-03-25 21:38:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5612kb
  • [2024-03-25 21:38:31]
  • 提交

answer

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

#define ls(x) ((x) << 1)
#define rs(x) ((x) << 1 | 1)
#define lowbit(x) ((x) & (-x))

const int N = 10010007;
const int M = 120;
const int INF = (1ull << 60) - 1;
const int mod = 998244353;
using pii = pair<int, int>;
using ll = long long;

struct node{
    int l;int r;
    int num;
}b[N];
int a[N];
int p[N];
int ans[N];
void solve(){   
    int n;
    cin >> n;
    cin >> a[0];
    const int P = 1e9 + 7;
    for (int i = 1;i <= n;i++)a[i] = (a[i - 1] * mod + P) % (P + 2);
    for (int i = 1;i <= n;i++)p[i] = i;
    for (int i = 1;i <= n;i++)swap(p[i], p[a[i] % i + 1]);
    //for (int i = 1;i <= n;i++)cout << p[i] << " ";cout << '\n';
    for (int i = 1;i <= n;i++){
        b[i].l = i - 1;
        b[i].r = i + 1;
        b[i].num = i;
    }

    int mid = (n + 1)/2;
    b[0].r = 1;
    b[n + 1].l = n;
    for (int i = n;i >= 1;i--){
        ans[i] = b[mid].num;
        //cout << ans[i] << '\n';
        int L = b[p[i]].l;
        int R = b[p[i]].r;
        b[L].r = R;
        b[R].l = L;
        if (i & 1){
            if (p[i] == b[mid].num)mid = b[mid].l;
            else if (p[i] > b[mid].num)mid = b[mid].l;
        }
        else{
            
            if (p[i] == b[mid].num)mid = b[mid].r;
            else if (p[i] < b[mid].num)mid = b[mid].r;
        }
    }
    int sum = 0;
    int res = 19;
    for (int i = 1;i <= n;i++){
        sum += ans[i] * res;
        sum %= mod;
        res *= 19;
        res %= mod;
    }
    cout << sum << '\n';
}
void init(int n,int k) {
    
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    //cin >> T;

    
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5612kb

input:

5 0

output:

7717914

result:

wrong answer 1st numbers differ - expected: '7703113', found: '7717914'