Submission #705329

# Submission time Handle Problem Language Result Execution time Memory
705329 2023-03-04T02:32:33 Z cig32 The Collection Game (BOI21_swaps) C++17
85 / 100
17 ms 436 KB
#include "swaps.h"
#include "bits/stdc++.h"
using namespace std;

int p[501], pos[501];
void block(int B, int N) {
  int count = 0;
  vector<pair<int,int> > queries;
  for(int k=1; k<=N; k+=(B<<1)) {
    for(int l=k; l<k+B; l++) {
      if((k<<1) + (B<<1) - 1 - l <= N) {
        count++;
        queries.push_back({p[l], p[k+k+(B<<1)-1-l]});
      }
    }
  }
  if(queries.empty())return;
  for(pair<int,int> x: queries) schedule(x.first,x.second);
  vector<int> res = visit();
  for(int i=0; i<res.size(); i++) {
    if(res[i] == 0) {
      // Then A[i] > A[j]
      swap(p[pos[queries[i].first]], p[pos[queries[i].second]]);
      for(int j=1; j<=N; j++) pos[p[j]] = j;
    }
  }
}
void solve(int N, int V) {
  // TODO implement this function
  for(int i=1; i<=N; i++) p[i] = pos[i] = i;
  int L = log2(N);
  for(int i=1; i<=9; i++) {
    int cc = 0;
    for(int j=(1<<L); j>=1; j>>=1) {
      cc++;
      if(cc>i+1) break;
      if(i==2 && j==(1<<L)/2) continue;
      block(j, N);
    }
  }
  vector<int> identity;
  for(int i=1; i<=N; i++) identity.push_back(p[i]);
  answer(identity);
}

Compilation message

swaps.cpp: In function 'void block(int, int)':
swaps.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0; i<res.size(); i++) {
      |                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 5 ms 208 KB Correct
4 Correct 10 ms 312 KB Correct
5 Correct 5 ms 316 KB Correct
6 Correct 7 ms 316 KB Correct
7 Correct 11 ms 404 KB Correct
8 Correct 12 ms 312 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 4 ms 208 KB Correct
4 Correct 10 ms 360 KB Correct
5 Correct 5 ms 304 KB Correct
6 Correct 7 ms 304 KB Correct
7 Correct 12 ms 428 KB Correct
8 Correct 12 ms 304 KB Correct
9 Correct 10 ms 308 KB Correct
10 Correct 5 ms 312 KB Correct
11 Correct 8 ms 308 KB Correct
12 Correct 13 ms 312 KB Correct
13 Correct 12 ms 312 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 2 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 316 KB Correct
5 Correct 1 ms 208 KB Correct
6 Correct 2 ms 208 KB Correct
7 Correct 7 ms 208 KB Correct
8 Correct 17 ms 312 KB Correct
9 Correct 5 ms 308 KB Correct
10 Correct 8 ms 312 KB Correct
11 Correct 12 ms 304 KB Correct
12 Correct 12 ms 308 KB Correct
13 Correct 1 ms 208 KB Correct
14 Correct 2 ms 208 KB Correct
15 Correct 5 ms 208 KB Correct
16 Correct 13 ms 308 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 312 KB Correct
5 Correct 5 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 312 KB Correct
5 Correct 5 ms 292 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 3 ms 208 KB Correct
9 Correct 9 ms 316 KB Correct
10 Correct 5 ms 312 KB Correct
11 Correct 7 ms 308 KB Correct
12 Correct 12 ms 420 KB Correct
13 Correct 12 ms 308 KB Correct
14 Correct 10 ms 308 KB Correct
15 Correct 5 ms 312 KB Correct
16 Correct 8 ms 312 KB Correct
17 Correct 11 ms 316 KB Correct
18 Correct 12 ms 304 KB Correct
19 Correct 1 ms 208 KB Correct
20 Correct 2 ms 208 KB Correct
21 Correct 5 ms 208 KB Correct
22 Correct 14 ms 308 KB Correct
23 Correct 13 ms 300 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 312 KB Correct
5 Correct 5 ms 312 KB Correct
6 Correct 5 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 312 KB Correct
5 Correct 5 ms 312 KB Correct
6 Correct 5 ms 292 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 2 ms 208 KB Correct
9 Correct 5 ms 208 KB Correct
10 Correct 10 ms 308 KB Correct
11 Correct 5 ms 312 KB Correct
12 Correct 7 ms 308 KB Correct
13 Correct 12 ms 308 KB Correct
14 Correct 12 ms 316 KB Correct
15 Correct 10 ms 436 KB Correct
16 Correct 4 ms 312 KB Correct
17 Correct 7 ms 312 KB Correct
18 Correct 12 ms 312 KB Correct
19 Correct 12 ms 312 KB Correct
20 Correct 1 ms 208 KB Correct
21 Correct 2 ms 288 KB Correct
22 Correct 5 ms 208 KB Correct
23 Correct 14 ms 304 KB Correct
24 Correct 14 ms 296 KB Correct
25 Correct 14 ms 288 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 6 ms 312 KB Correct
5 Correct 5 ms 312 KB Correct
6 Correct 4 ms 288 KB Correct
7 Runtime error 5 ms 292 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 6 ms 312 KB Correct
5 Correct 5 ms 312 KB Correct
6 Correct 4 ms 288 KB Correct
7 Runtime error 5 ms 292 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -