Submission #905292

# Submission time Handle Problem Language Result Execution time Memory
905292 2024-01-12T22:33:07 Z Ahmed57 The Collection Game (BOI21_swaps) C++17
25 / 100
23 ms 672 KB
#include <bits/stdc++.h>
using namespace std;
#include "swaps.h"
 
int a[2001] = {0}; 
int n , xd;
int x = 0;
void compp(int a,int b){
    if(b<=n&&a<=n){
        schedule(a,b); 
        x++;
    }
}
void bitonic(int l, int r, bool inc, bool all){
    if(l==r)return ;
    assert(l<=r);
    int md=(l+r)/2;
    assert(((l+r)%2)==1);
    if(all){
    bitonic(l,md,inc,1);
    bitonic(md+1,r,!inc,1);
    }
    for(int i = l;i<=md;i++){
        assert(i+md+1-l<=xd);
        assert(i+md+1-l>md);
        compp(a[i],a[i+md+1-l]);
    }
    vector<int> vi = visit();
    //if(vi.size()!=x)assert(0);
    x = 0;
    int ind = 0;
    for(int i = l;i<=md;i++){
        assert(i+md+1-l<=xd);
        assert(i+md+1-l>md);
        if(a[i+md+1-l]>n){
            if(inc){
                swap(a[i],a[i+(md+1-l)]);
            }
        }else if(a[i]>n){
            if(!inc){
                swap(a[i],a[i+(md+1-l)]);
            }
        }else{
            if(ind>=vi.size())continue;
            if((!inc)^(!vi[ind])){
                swap(a[i],a[i+(md+1-l)]);
            }
            ind++;
        }
    }
    bitonic(l,md,inc,0);
    bitonic(md+1,r,inc,0);
}
void solve(int N,int V){
    n = N;
    xd = 1;
    while(xd<N)xd*=2;
    for(int i = 1;i<=xd;i++){
        a[i] = i;
    }
    bitonic(1,xd,1,1);
    vector<int> ans;
    for(int i = xd-N+1;i<=xd;i++){
        ans.push_back(a[i]);
    }
    answer(ans);
}

Compilation message

swaps.cpp: In function 'void bitonic(int, int, bool, bool)':
swaps.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if(ind>=vi.size())continue;
      |                ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 10 ms 444 KB Correct
4 Correct 23 ms 672 KB Correct
5 Correct 19 ms 432 KB Correct
6 Correct 18 ms 436 KB Correct
7 Correct 20 ms 424 KB Correct
8 Correct 19 ms 436 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 340 KB Correct
3 Correct 8 ms 440 KB Correct
4 Correct 20 ms 424 KB Correct
5 Correct 23 ms 416 KB Correct
6 Correct 18 ms 424 KB Correct
7 Correct 20 ms 420 KB Correct
8 Correct 23 ms 420 KB Correct
9 Runtime error 5 ms 444 KB Execution killed with signal 13
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 3 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 3 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 4 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 8 ms 436 KB Correct
4 Correct 19 ms 432 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 8 ms 436 KB Correct
4 Correct 19 ms 432 KB Correct
5 Correct 1 ms 344 KB Correct
6 Correct 4 ms 344 KB Correct
7 Correct 8 ms 436 KB Correct
8 Correct 20 ms 416 KB Correct
9 Correct 19 ms 420 KB Correct
10 Correct 19 ms 420 KB Correct
11 Correct 20 ms 420 KB Correct
12 Correct 18 ms 436 KB Correct
13 Correct 1 ms 344 KB Correct
14 Correct 4 ms 344 KB Correct
15 Correct 10 ms 436 KB Correct
16 Correct 19 ms 420 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Correct
2 Correct 3 ms 344 KB Correct
3 Correct 8 ms 432 KB Correct
4 Correct 19 ms 596 KB Correct
5 Runtime error 2 ms 600 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Correct
2 Correct 3 ms 344 KB Correct
3 Correct 8 ms 432 KB Correct
4 Correct 19 ms 596 KB Correct
5 Runtime error 2 ms 600 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 12 ms 412 KB Correct
4 Correct 19 ms 420 KB Correct
5 Runtime error 3 ms 436 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 12 ms 412 KB Correct
4 Correct 19 ms 420 KB Correct
5 Runtime error 3 ms 436 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 10 ms 444 KB Correct
4 Correct 20 ms 436 KB Correct
5 Runtime error 3 ms 440 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 4 ms 344 KB Correct
3 Correct 10 ms 444 KB Correct
4 Correct 20 ms 436 KB Correct
5 Runtime error 3 ms 440 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -