Submission #1078825

# Submission time Handle Problem Language Result Execution time Memory
1078825 2024-08-28T06:39:32 Z raphaelp Broken Device (JOI17_broken_device) C++14
0 / 100
2 ms 856 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna(int N, long long X, int K, int P[])
{
    map<vector<int>, vector<int>> M;
    M[{1, 1}] = {1, 1, 1};
    M[{1}] = {1, 1, 0};
    M[{1, 0}] = {1, 0, 1};
    M[{0}] = {1, 0, 0};
    M[{0, 1}] = {0, 1, 1};
    M[{0, 0}] = {0, 1, 0};
    vector<int> P2(N);
    for (int i = 0; i < K; i++)
        P2[P[i]] = 1;
    vector<int> ans(N);
    int buff = 0;
    vector<int> bits;
    while (X)
    {
        bits.push_back(X % 2);
        X /= 2;
    }
    reverse(bits.begin(), bits.end());
    for (int i = 0; i < 150; i += 3)
    {
        if (buff == bits.size())
            break;
        vector<int> temp;
        if (P2[i] + P2[i + 2] + P2[i + 2] > 1)
            continue;
        if (P2[i] == 1)
        {
            if (bits[buff] == 1)
            {
                temp = {0, 0, 1};
                buff++;
            }
            if (buff < bits.size() - 1 && bits[buff] == 0)
            {
                temp = M[{bits[buff], bits[buff + 1]}];
                buff += 2;
            }
        }
        else if (P2[i + 1] == 1)
        {
            if (bits[buff] == 1)
                temp = {0, 0, 1};
            else
                temp = {1, 0, 0};
            buff++;
        }
        else if (P2[i + 2] == 1)
        {
            if (bits[buff] == 1)
                temp = {1, 1, 0};
            else
                temp = {1, 0, 0};
        }
        else
        {
            if (buff < bits.size() - 1)
            {
                temp = M[{bits[buff], bits[buff + 1]}];
                buff += 2;
            }
            else
            {
                temp = M[{bits[buff]}];
                buff++;
            }
        }
        ans[i] = temp[0], ans[i + 1] = temp[1], ans[i + 2] = temp[2];
    }
    for (int i = 0; i < N; i++)
    {
        // cout << ans[i] << ' ';
        Set(i, ans[i]);
    }
}
/*int main()
{
    long long N, X, K;
    cin >> N >> X >> K;
    long long P[N];
    srand(time(0));
    for (long long i = 0; i < K; i++)
        P[i] = rand() % N;
    Anna(N, X, K, P);
}*/
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N, int A[])
{
    map<vector<int>, vector<int>> M;
    M[{1, 1, 1}] = {1, 1};
    M[{1, 1, 0}] = {1};
    M[{1, 0, 1}] = {1, 0};
    M[{1, 0, 0}] = {0};
    M[{0, 1, 1}] = {0, 1};
    M[{0, 1, 0}] = {0, 0};
    M[{0, 0, 1}] = {1};
    long long X = 0;
    for (int i = 0; i < 150; i += 3)
    {
        vector<int> temp = {A[i], A[i + 1], A[i + 2]};
        if (temp[0] + temp[1] + temp[2] == 0)
            continue;
        else
            temp = M[temp];
        for (int j = 0; j < temp.size(); j++)
        {
            X *= 2;
            X += temp[j];
        }
    }
    return X;
}
/*int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
        cin >> A[i];
    cout << Bruno(N, A);
}*/

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         if (buff == bits.size())
      |             ~~~~~^~~~~~~~~~~~~~
Anna.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if (buff < bits.size() - 1 && bits[buff] == 0)
      |                 ~~~~~^~~~~~~~~~~~~~~~~
Anna.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if (buff < bits.size() - 1)
      |                 ~~~~~^~~~~~~~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < temp.size(); j++)
      |                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Runtime error 1 ms 604 KB Execution killed with signal 11
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Runtime error 1 ms 604 KB Execution killed with signal 11
8 Runtime error 1 ms 608 KB Execution killed with signal 11
9 Runtime error 1 ms 604 KB Execution killed with signal 11
10 Runtime error 1 ms 604 KB Execution killed with signal 11
11 Runtime error 1 ms 604 KB Execution killed with signal 11
12 Runtime error 1 ms 604 KB Execution killed with signal 11
13 Runtime error 1 ms 604 KB Execution killed with signal 11
14 Runtime error 1 ms 600 KB Execution killed with signal 11
15 Runtime error 1 ms 604 KB Execution killed with signal 11
16 Runtime error 1 ms 604 KB Execution killed with signal 11
17 Runtime error 1 ms 600 KB Execution killed with signal 11
18 Runtime error 2 ms 604 KB Execution killed with signal 11
19 Runtime error 1 ms 856 KB Execution killed with signal 11
20 Runtime error 1 ms 604 KB Execution killed with signal 11
21 Runtime error 1 ms 604 KB Execution killed with signal 11
22 Runtime error 1 ms 600 KB Execution killed with signal 11
23 Runtime error 1 ms 348 KB Execution killed with signal 11
24 Runtime error 1 ms 604 KB Execution killed with signal 11
25 Runtime error 1 ms 600 KB Execution killed with signal 11
26 Runtime error 1 ms 604 KB Execution killed with signal 11
27 Runtime error 1 ms 604 KB Execution killed with signal 11
28 Runtime error 1 ms 604 KB Execution killed with signal 11
29 Runtime error 1 ms 564 KB Execution killed with signal 11
30 Runtime error 1 ms 604 KB Execution killed with signal 11
31 Runtime error 1 ms 856 KB Execution killed with signal 11
32 Runtime error 1 ms 604 KB Execution killed with signal 11
33 Runtime error 1 ms 604 KB Execution killed with signal 11
34 Runtime error 1 ms 604 KB Execution killed with signal 11
35 Runtime error 1 ms 604 KB Execution killed with signal 11
36 Runtime error 1 ms 604 KB Execution killed with signal 11
37 Runtime error 1 ms 604 KB Execution killed with signal 11
38 Runtime error 1 ms 604 KB Execution killed with signal 11
39 Runtime error 1 ms 604 KB Execution killed with signal 11
40 Runtime error 1 ms 604 KB Execution killed with signal 11