Submission #549360

# Submission time Handle Problem Language Result Execution time Memory
549360 2022-04-15T17:13:47 Z Lobo Broken Device (JOI17_broken_device) C++17
81 / 100
50 ms 2700 KB
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = 280;

void Anna(int32_t N, int X, int32_t K, int32_t P[]) {
    int mark[N+10];
    int n = N;
    for(int i = 0; i < n; i++) {
        mark[i] = 0;
    }

    for(int i = 0; i < K; i++) {
        int p = P[i];
        mark[p] = 1;
        if(p%2 == 0) {
            mark[p+1] = 1;
        }
        else {
            mark[p-1] = 1;
        }
    }

    string s;
    //escreve X aqui
    for(int i = 0; i < 60; i+= 3) {
        int a = ((X&(1LL<<i)) != 0);
        int b = ((X&(1LL<<(i+1))) != 0);
        int c = ((X&(1LL<<(i+2))) != 0);
        string s1;
        if(a == 0 && b == 0 && c == 0) {
            s1 = "1010";
        }
        else if(a == 1 && b == 0 && c == 0) {
            s1 = "1011";
        }
        else {
            if(a == 0) s1+= '0';
            else s1+= '1';
            s1+= '1';
            if(b == 0) s1+= '0';
            else s1+= '1';
            if(c == 0) s1+= '0';
            else s1+= '1';
        }

        s+= s1;
    }

    string ans;
    int id = 0;
    for(int i = 0; i < n; i++) {
        if(mark[i] || id == s.size()) {
            ans+= '0';
        }
        else {
            ans+= s[id++];
        }
    }

    for(int i = 0; i < n; i++) {
        if(ans[i] == '0') Set(i,0);
        else Set(i,1);
    }
}

// int32_t main() {
//     ios::sync_with_stdio(false); cin.tie(0);

//     freopen("in.in", "r", stdin);
//     // freopen("out.out", "w", stdout);
    
//     int32_t N,X,K;
//     cin >> N >> X >> K;
//     int32_t P[K];
//     for(int i = 0; i < K; i++) {
//         cin >> P[i];
//     }

//     Anna(N,X,K,P);

// }
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = -1;

int Bruno(int32_t N, int32_t A[]) {
    int n = N;
    string s;
    for(int i = 0; i < n; i+=2) {
        if(A[i] == 0 && A[i+1] == 0) {
            continue;
        }

        s+= (char) A[i]+'0';
        s+= (char) A[i+1]+'0';
    }

    int x = 0;
    for(int i = 0, pt = 0; i < s.size(); pt+= 3, i+= 4) {
        string s1;
        s1+= s[i];
        s1+= s[i+1];
        s1+= s[i+2];
        s1+= s[i+3];
        int a,b,c;
        if(s1 == "1010") {
            a = 0;
            b = 0;
            c = 0;
        }
        else if(s1 == "1011") {
            a = 1;
            b = 0;
            c = 0;
        }
        else {
            if(s1[0] == '0') a = 0;
            else a = 1;
            if(s1[2] == '0') b = 0;
            else b = 1;
            if(s1[3] == '0') c = 0;
            else c = 1;
        }

        x+= a*(1LL<<pt);
        x+= b*(1LL<<(pt+1));
        x+= c*(1LL<<(pt+2));
    }

    return x;
}

// int32_t main() {
//     ios::sync_with_stdio(false); cin.tie(0);

//     freopen("in.in", "r", stdin);
//     // freopen("out.out", "w", stdout);
    
    
//     int32_t N; cin >> N;
//     int32_t A[N];
//     string s; cin >> s;
//     for(int i = 0; i < N; i++) {
//         if(s[i] == '0') A[i] = 0;
//         else A[i] = 1;
//     }
//     cout << Bruno(N,A) << endl;

// }

Compilation message

Anna.cpp: In function 'void Anna(int32_t, long long int, int32_t, int32_t*)':
Anna.cpp:65:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         if(mark[i] || id == s.size()) {
      |                       ~~~^~~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int32_t, int32_t*)':
Bruno.cpp:31:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0, pt = 0; i < s.size(); pt+= 3, i+= 4) {
      |                            ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 38 ms 2444 KB Output is partially correct - L* = 35
2 Partially correct 36 ms 2424 KB Output is partially correct - L* = 37
3 Partially correct 34 ms 2440 KB Output is partially correct - L* = 35
4 Partially correct 37 ms 2544 KB Output is partially correct - L* = 35
5 Partially correct 34 ms 2612 KB Output is partially correct - L* = 35
6 Partially correct 37 ms 2572 KB Output is partially correct - L* = 35
7 Partially correct 43 ms 2648 KB Output is partially correct - L* = 35
8 Partially correct 39 ms 2496 KB Output is partially correct - L* = 35
9 Partially correct 35 ms 2576 KB Output is partially correct - L* = 35
10 Partially correct 35 ms 2516 KB Output is partially correct - L* = 35
11 Partially correct 37 ms 2580 KB Output is partially correct - L* = 35
12 Partially correct 35 ms 2524 KB Output is partially correct - L* = 36
13 Partially correct 38 ms 2480 KB Output is partially correct - L* = 35
14 Partially correct 39 ms 2460 KB Output is partially correct - L* = 35
15 Partially correct 34 ms 2456 KB Output is partially correct - L* = 35
16 Partially correct 35 ms 2528 KB Output is partially correct - L* = 35
17 Partially correct 35 ms 2480 KB Output is partially correct - L* = 35
18 Partially correct 33 ms 2460 KB Output is partially correct - L* = 35
19 Partially correct 39 ms 2548 KB Output is partially correct - L* = 35
20 Partially correct 39 ms 2440 KB Output is partially correct - L* = 35
21 Partially correct 35 ms 2468 KB Output is partially correct - L* = 35
22 Partially correct 35 ms 2700 KB Output is partially correct - L* = 35
23 Partially correct 35 ms 2500 KB Output is partially correct - L* = 35
24 Partially correct 38 ms 2496 KB Output is partially correct - L* = 35
25 Partially correct 37 ms 2452 KB Output is partially correct - L* = 35
26 Partially correct 46 ms 2448 KB Output is partially correct - L* = 35
27 Partially correct 38 ms 2428 KB Output is partially correct - L* = 35
28 Partially correct 34 ms 2588 KB Output is partially correct - L* = 35
29 Partially correct 36 ms 2480 KB Output is partially correct - L* = 35
30 Partially correct 35 ms 2548 KB Output is partially correct - L* = 35
31 Partially correct 46 ms 2436 KB Output is partially correct - L* = 35
32 Partially correct 46 ms 2656 KB Output is partially correct - L* = 35
33 Partially correct 36 ms 2488 KB Output is partially correct - L* = 35
34 Partially correct 36 ms 2468 KB Output is partially correct - L* = 35
35 Partially correct 36 ms 2472 KB Output is partially correct - L* = 35
36 Partially correct 44 ms 2492 KB Output is partially correct - L* = 35
37 Partially correct 37 ms 2588 KB Output is partially correct - L* = 35
38 Partially correct 43 ms 2600 KB Output is partially correct - L* = 35
39 Partially correct 50 ms 2496 KB Output is partially correct - L* = 35
40 Partially correct 40 ms 2644 KB Output is partially correct - L* = 35