Submission #821728

# Submission time Handle Problem Language Result Execution time Memory
821728 2023-08-11T14:02:03 Z alvingogo The Collection Game (BOI21_swaps) C++14
100 / 100
5 ms 444 KB
#include "swaps.h"
#include <bits/stdc++.h>
#define fs first
#define sc second
using namespace std;

void solve(int n, int v) {
    vector<int> a(n);
    iota(a.begin(),a.end(),1);
    for(int p=1;p<n;p<<=1){
        for(int k=p;k>=1;k>>=1){
            vector<pair<int,int> > nw;
            for(int j=k%p;j+k<n;j+=2*k){
                for(int i=0;i+j+k<n && i<k;i++){
                    if((i+j)/(p*2) == (i+j+k)/(p*2)){
                        nw.push_back({i+j,i+j+k});
                        schedule(a[i+j],a[i+j+k]);
                    }
                }
            }
            auto h=visit();
            for(int i=0;i<nw.size();i++){
                if(!h[i]){
                    swap(a[nw[i].fs],a[nw[i].sc]);
                }
            }
        }
    }
    answer(a);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int i=0;i<nw.size();i++){
      |                         ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 1 ms 300 KB Correct
4 Correct 3 ms 316 KB Correct
5 Correct 3 ms 312 KB Correct
6 Correct 3 ms 312 KB Correct
7 Correct 3 ms 312 KB Correct
8 Correct 3 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 3 ms 312 KB Correct
6 Correct 3 ms 308 KB Correct
7 Correct 3 ms 316 KB Correct
8 Correct 3 ms 316 KB Correct
9 Correct 4 ms 308 KB Correct
10 Correct 3 ms 312 KB Correct
11 Correct 3 ms 320 KB Correct
12 Correct 4 ms 312 KB Correct
13 Correct 3 ms 308 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 1 ms 296 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 312 KB Correct
4 Correct 3 ms 308 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 312 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 1 ms 292 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 2 ms 208 KB Correct
8 Correct 3 ms 304 KB Correct
9 Correct 3 ms 316 KB Correct
10 Correct 3 ms 312 KB Correct
11 Correct 3 ms 312 KB Correct
12 Correct 3 ms 312 KB Correct
13 Correct 0 ms 208 KB Correct
14 Correct 1 ms 208 KB Correct
15 Correct 2 ms 208 KB Correct
16 Correct 5 ms 308 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 292 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 3 ms 320 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 292 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 308 KB Correct
5 Correct 3 ms 320 KB Correct
6 Correct 0 ms 208 KB Correct
7 Correct 1 ms 228 KB Correct
8 Correct 2 ms 208 KB Correct
9 Correct 3 ms 320 KB Correct
10 Correct 4 ms 316 KB Correct
11 Correct 4 ms 316 KB Correct
12 Correct 3 ms 308 KB Correct
13 Correct 3 ms 308 KB Correct
14 Correct 3 ms 308 KB Correct
15 Correct 3 ms 312 KB Correct
16 Correct 3 ms 308 KB Correct
17 Correct 4 ms 308 KB Correct
18 Correct 3 ms 312 KB Correct
19 Correct 0 ms 208 KB Correct
20 Correct 1 ms 208 KB Correct
21 Correct 2 ms 304 KB Correct
22 Correct 4 ms 312 KB Correct
23 Correct 3 ms 288 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 312 KB Correct
5 Correct 3 ms 300 KB Correct
6 Correct 3 ms 272 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 312 KB Correct
5 Correct 3 ms 300 KB Correct
6 Correct 3 ms 272 KB Correct
7 Correct 0 ms 208 KB Correct
8 Correct 1 ms 208 KB Correct
9 Correct 2 ms 208 KB Correct
10 Correct 3 ms 316 KB Correct
11 Correct 3 ms 308 KB Correct
12 Correct 3 ms 312 KB Correct
13 Correct 3 ms 428 KB Correct
14 Correct 3 ms 308 KB Correct
15 Correct 3 ms 308 KB Correct
16 Correct 3 ms 308 KB Correct
17 Correct 3 ms 316 KB Correct
18 Correct 3 ms 316 KB Correct
19 Correct 4 ms 304 KB Correct
20 Correct 0 ms 208 KB Correct
21 Correct 1 ms 208 KB Correct
22 Correct 2 ms 208 KB Correct
23 Correct 3 ms 308 KB Correct
24 Correct 3 ms 288 KB Correct
25 Correct 3 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 316 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 312 KB Correct
5 Correct 3 ms 308 KB Correct
6 Correct 3 ms 316 KB Correct
7 Correct 4 ms 284 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 1 ms 316 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 3 ms 312 KB Correct
5 Correct 3 ms 308 KB Correct
6 Correct 3 ms 316 KB Correct
7 Correct 4 ms 284 KB Correct
8 Correct 0 ms 208 KB Correct
9 Correct 0 ms 208 KB Correct
10 Correct 1 ms 208 KB Correct
11 Correct 2 ms 208 KB Correct
12 Correct 3 ms 312 KB Correct
13 Correct 3 ms 312 KB Correct
14 Correct 3 ms 308 KB Correct
15 Correct 3 ms 312 KB Correct
16 Correct 4 ms 444 KB Correct
17 Correct 3 ms 308 KB Correct
18 Correct 3 ms 304 KB Correct
19 Correct 4 ms 308 KB Correct
20 Correct 4 ms 308 KB Correct
21 Correct 3 ms 312 KB Correct
22 Correct 0 ms 208 KB Correct
23 Correct 1 ms 208 KB Correct
24 Correct 2 ms 208 KB Correct
25 Correct 3 ms 308 KB Correct
26 Correct 3 ms 304 KB Correct
27 Correct 4 ms 284 KB Correct
28 Correct 4 ms 268 KB Correct