Submission #467821

# Submission time Handle Problem Language Result Execution time Memory
467821 2021-08-24T20:56:18 Z blue The Collection Game (BOI21_swaps) C++17
0 / 100
1 ms 200 KB
#include "swaps.h"
#include <vector>
#include <iostream>
using namespace std;

int N;
int V;

vector<int> r;

void do_comparisons(vector<int> A, vector<int> B)
{
    if(A.size() == 0) return;

    for(int i = 0; i < A.size(); i++)
    {
        schedule(r[ A[i] ], r[ B[i] ]);
    }

    vector<int> C = visit();

    for(int i = 0; i < A.size(); i++)
    {
        if(C[i] == 0)
            swap(r[ A[i] ], r[ B[i] ]);
    }
}

void solve(int n, int v)
{
    N = n;
    V = v;
    r = vector<int>(N);
    for(int i = 1; i <= N; i++) r[i - 1] = i;

    for(int p = 1; p < N; p *= 2)
    {
        for(int k = p; k >= 1; k /= 2)
        {
            vector<int> A, B;
            for(int j = k; j <= n-1-k; j += 2*k)
            {
                for(int i = 0; i <= k-1 && i+j+k < N; i++)
                {
                    if((i+j)/(2*p) == (i+j+k)/(2*p))
                    {
                        A.push_back(i+j);
                        B.push_back(i+j+k);
                    }
                }
            }
            do_comparisons(A, B);
        }
    }

    answer(r);
}

Compilation message

swaps.cpp: In function 'void do_comparisons(std::vector<int>, std::vector<int>)':
swaps.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
swaps.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -