QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586807#9249. Elimination Series Once Moregaofeng#WA 1ms7748kbC++201.1kb2024-09-24 15:42:112024-09-24 15:42:11

Judging History

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

  • [2024-09-24 15:42:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7748kb
  • [2024-09-24 15:42:11]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
// #define int long long
typedef pair<int,int> PII;
const int N = 3e6 + 10;
const int mod = 998244353;

int n,m;
PII a[N], temp[N];
int res[N];
void dfs(int l, int r){
    if(l >= r)return;
    if(l+1 == r){
        res[a[l].second] = 0;return;
    }
    int mid = l + r >> 1;
    dfs(l, mid);dfs(mid, r);
    int i = l, j = mid, k = l;
    while(i < mid){
        while(j < r && a[j].first < a[i].first)temp[k++] = a[j++];
        temp[k++] = a[i++];
    }
    while(j < r)temp[k++] = a[j++];
    for(k=l; k<r; ++k){
        a[k] = temp[k];
        if(r - k - 1 <= m && r - k - 1 <= (1<<n) - (r - l) && r - k - 1 < a[k].first)res[a[k].second]++;
    }
}

void solve() {
    cin >> n >> m;
    for(int i=0; i<1<<n; ++i)cin >> a[i].first, a[i].second = i;
    dfs(0, 1<<n);
    for(int i=0; i<1<<n; ++i)cout << res[i] << " \n"[i == (1<<n)-1];
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1
1 2 3 4

output:

0 1 1 2

result:

ok 4 number(s): "0 1 1 2"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7676kb

input:

3 5
2 4 7 5 3 8 6 1

output:

1 2 2 2 2 3 2 0

result:

wrong answer 5th numbers differ - expected: '1', found: '2'