답안 #643092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643092 2022-09-21T07:58:46 Z cologne Broken Device 2 (JOI22_device2) C++17
0 / 100
11 ms 812 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

int Declare()
{
    return 2000;
}
namespace
{
    long long count(int N)
    {
        long long R = 0;
        for (int K = 0; (2 << K) - 2 <= N; K++)
            R = max(R, (long long)(2 * (N - ((2 << K) - 2)) + 1) << (2 * K));
        return R;
    }

    int findK(int N)
    {
        long long R = 0;
        int ak = 0;
        for (int K = 0; (2 << K) - 2 <= N; K++)
        {
            long long v = (long long)(2 * (N - ((2 << K) - 2)) + 1) << (2 * K);
            if (R < v)
                R = v, ak = K;
        }
        return ak;
    }

    pair<vector<int>, vector<int>> solve(int N, long long A)
    {
        vector<int> L(N), R(N);
        int K = findK(N);
        for (int i = 0; i < K; i++)
        {
            fill(L.begin() + (1 << i) - 1, L.begin() + (2 << i) - 1, A & 1);
            fill(R.begin() + (1 << i) - 1, R.begin() + (2 << i) - 1, A & 1);
            A >>= 1;
            fill(L.end() - ((2 << i) - 1), L.end() - ((1 << i) - 1), A & 1);
            fill(R.end() - ((2 << i) - 1), R.end() - ((1 << i) - 1), A & 1);
            A >>= 1;
        }
        for (int i = 0; i < A; i++)
            if (i & 1)
                R[(1 << K) - 1 + i / 2] = 1;
            else
                L[(1 << K) - 1 + i / 2] = 1;
        return {L, R};
    }
}

pair<vector<int>, vector<int>> Anna(long long A)
{
    --A;
    for (int i = 1; i <= 2000; i++)
    {
        long long K = count(i);
        if (A >= K)
            A -= K;
        else
            return solve(i, A);
    }
    assert(false);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
    long long count(int N)
    {
        long long R = 0;
        for (int K = 0; (2 << K) - 2 <= N; K++)
            R = max(R, (long long)(2 * (N - ((2 << K) - 2)) + 1) << (2 * K));
        return R;
    }

    int findK(int N)
    {
        long long R = 0;
        int ak = 0;
        for (int K = 0; (2 << K) - 2 <= N; K++)
        {
            long long v = (long long)(2 * (N - ((2 << K) - 2)) + 1) << (2 * K);
            if (R < v)
                R = v, ak = K;
        }
        return ak;
    }

    long long solve(vector<int> u)
    {
        int N = u.size() / 2;
        int k = findK(N);
        long long x = count(u.begin(), u.end(), 1);
        long long bs = 0;
        int deg = 0;
        for(int i=0; i<k; i++)
        {
            long long L = u[(2<<i)-2], R = u[(2*N-1)-((2<<i)-2)];
            bs += L << (deg++);
            bs += R << (deg++);
            x -= L << (i+1);
            x -= R << (i+1);
        }
        return (x << deg) + bs;
    }
}
long long Bruno(vector<int> u)
{
    long long ans = 1;
    for (int i = 1; i < (int)u.size() / 2; i++)
        ans += count(i);

    return ans + solve(u);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 11 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 11 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 11 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 11 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Incorrect 11 ms 812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -