Submission #705432

# Submission time Handle Problem Language Result Execution time Memory
705432 2023-03-04T11:05:10 Z lukameladze Broken Device (JOI17_broken_device) C++14
0 / 100
2 ms 524 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1


// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01


// 7 ---- > 11
void assign(int idx, int val) {
    if (val >= 4) Set(idx, 1), val -= 4; else Set(idx, 0);
    if (val >= 2) Set(idx + 1, 1), val -= 2; else Set(idx + 1, 0);
    if (val >= 1) Set(idx + 2, 1), val -= 1; else Set(idx + 2, 0);
}
void Anna( int N, long long X, int K, int P[] ){
    std::vector <int> bit, fix;
    bit = vector <int> (65, 0);
    fix = vector <int> (155, 0);
    for (int i = 0; i < 60; i++) {
        bit[i] = ((1LL<<i)&X ? 1 : 0);
    }
    for (int i = 0; i < K; i++) {
        fix[P[i]] = 1;
    }
    int cur = 0;
    for (int i = 0; i < 150; i+=3) {
        if (cur >= 60) {
            for (int j = i; j < 150; j+=3) {
                assign(j, 0);
            }
            break;
        }
        int bl = fix[i] + fix[i + 1] + fix[i + 2];
        if (bl >= 2) {
            assign(i, 0);
            continue;
        }
        if (bl == 0) {
            int val = bit[cur] * 2 + bit[cur + 1];
//            cout<<cur<<" "<<bit[cur]<<" "<<bit[cur + 1]<<"\n";
            cur += 2;
            if (val == 3) {
                assign(i, 7); continue;
            }
            if (val == 0) {
                assign(i, 4); continue;
            }
            if (val == 1) {
                assign(i, 6); continue;
            }
            if (val == 2) {
                assign(i, 3); continue;
            }
//            cout<<bl<<"    "<<val<<"\n";
        }
        assert(bl == 1);
        int val = bit[cur];
        if (!fix[i + 2] && val == 0) {
            cur++; assign(i, 1); continue;
        }
        if (!fix[i + 1] && val == 1) {
            cur++; assign(i, 2); continue;
        }
        int val1 = bit[cur + 1];
        if (val == 0) { // i da i + 1 emp
            if (val1 == 0) { 
                assign(i, 4); cur += 2; continue;
            }
            if (val1 == 1) { 
                assign(i, 6); cur += 2; continue;
            }
        }
        // i da i + 2 emp
        if (val1 == 0) {
            assign(i, 5); cur++; continue;
        }
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1


// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01


// 7 ---- > 11
long long Bruno( int N, int A[] ){
    string get[10];
    get[0] = "";
    get[1] = "0";
    get[2] = "1";
    get[5] = "1";
    get[3] = "10";
    get[4] = "00";
    get[6] = "01";
    get[7] = "11";
    string ans = "";
    for (int i = 0; i < 150; i += 3) {
        int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
        ans += get[x];
    }
    long long res = 0;
    for (int i = 0; i < ans.size(); i++) {
        res += (ans[i] == '1' ? (1LL<<i) : 0);
    }
    return res;
}

Compilation message

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 512 KB Wrong Answer [4]
2 Incorrect 0 ms 520 KB Wrong Answer [4]
3 Incorrect 0 ms 520 KB Wrong Answer [4]
4 Incorrect 0 ms 512 KB Wrong Answer [4]
5 Incorrect 0 ms 520 KB Wrong Answer [4]
6 Incorrect 0 ms 520 KB Wrong Answer [4]
7 Incorrect 0 ms 520 KB Wrong Answer [4]
8 Incorrect 0 ms 524 KB Wrong Answer [4]
9 Incorrect 1 ms 520 KB Wrong Answer [4]
10 Incorrect 2 ms 512 KB Wrong Answer [4]
11 Incorrect 0 ms 508 KB Wrong Answer [4]
12 Incorrect 0 ms 520 KB Wrong Answer [4]
13 Incorrect 0 ms 512 KB Wrong Answer [4]
14 Incorrect 0 ms 512 KB Wrong Answer [4]
15 Incorrect 1 ms 520 KB Wrong Answer [4]
16 Incorrect 0 ms 520 KB Wrong Answer [4]
17 Incorrect 0 ms 512 KB Wrong Answer [4]
18 Incorrect 0 ms 512 KB Wrong Answer [4]
19 Incorrect 0 ms 520 KB Wrong Answer [4]
20 Incorrect 0 ms 520 KB Wrong Answer [4]
21 Incorrect 1 ms 508 KB Wrong Answer [4]
22 Incorrect 1 ms 512 KB Wrong Answer [4]
23 Incorrect 0 ms 520 KB Wrong Answer [4]
24 Incorrect 1 ms 520 KB Wrong Answer [4]
25 Incorrect 0 ms 520 KB Wrong Answer [4]
26 Incorrect 0 ms 512 KB Wrong Answer [4]
27 Incorrect 0 ms 512 KB Wrong Answer [4]
28 Incorrect 1 ms 512 KB Wrong Answer [4]
29 Incorrect 0 ms 520 KB Wrong Answer [4]
30 Incorrect 0 ms 520 KB Wrong Answer [4]
31 Incorrect 0 ms 512 KB Wrong Answer [4]
32 Incorrect 0 ms 520 KB Wrong Answer [4]
33 Incorrect 0 ms 520 KB Wrong Answer [4]
34 Incorrect 0 ms 520 KB Wrong Answer [4]
35 Incorrect 0 ms 520 KB Wrong Answer [4]
36 Incorrect 0 ms 516 KB Wrong Answer [4]
37 Incorrect 0 ms 520 KB Wrong Answer [4]
38 Incorrect 0 ms 516 KB Wrong Answer [4]
39 Incorrect 0 ms 512 KB Wrong Answer [4]
40 Incorrect 0 ms 520 KB Wrong Answer [4]