Submission #549356

# Submission time Handle Problem Language Result Execution time Memory
549356 2022-04-15T16:59:19 Z Lobo Broken Device (JOI17_broken_device) C++17
0 / 100
40 ms 2448 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;

int mark[maxn];

void Anna(int32_t N, int X, int32_t K, int32_t P[]) {
    int n = N;
    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:62: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]
   62 |         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 32 ms 2220 KB Output isn't correct - L* = 0
2 Partially correct 30 ms 2280 KB Output isn't correct - L* = 0
3 Partially correct 33 ms 2240 KB Output isn't correct - L* = 0
4 Partially correct 37 ms 2292 KB Output isn't correct - L* = 0
5 Partially correct 36 ms 2200 KB Output isn't correct - L* = 0
6 Partially correct 36 ms 2296 KB Output isn't correct - L* = 0
7 Partially correct 34 ms 2348 KB Output isn't correct - L* = 0
8 Partially correct 31 ms 2360 KB Output isn't correct - L* = 0
9 Partially correct 32 ms 2172 KB Output isn't correct - L* = 0
10 Partially correct 32 ms 2360 KB Output isn't correct - L* = 0
11 Partially correct 33 ms 2244 KB Output isn't correct - L* = 0
12 Partially correct 33 ms 2232 KB Output isn't correct - L* = 0
13 Partially correct 32 ms 2232 KB Output isn't correct - L* = 0
14 Partially correct 33 ms 2332 KB Output isn't correct - L* = 0
15 Partially correct 31 ms 2312 KB Output isn't correct - L* = 0
16 Partially correct 33 ms 2244 KB Output isn't correct - L* = 0
17 Partially correct 33 ms 2232 KB Output isn't correct - L* = 0
18 Partially correct 33 ms 2256 KB Output isn't correct - L* = 0
19 Partially correct 33 ms 2248 KB Output isn't correct - L* = 0
20 Partially correct 35 ms 2344 KB Output isn't correct - L* = 0
21 Partially correct 35 ms 2372 KB Output isn't correct - L* = 0
22 Partially correct 34 ms 2252 KB Output isn't correct - L* = 0
23 Partially correct 34 ms 2336 KB Output isn't correct - L* = 0
24 Partially correct 32 ms 2256 KB Output isn't correct - L* = 0
25 Partially correct 32 ms 2448 KB Output isn't correct - L* = 0
26 Partially correct 40 ms 2172 KB Output isn't correct - L* = 0
27 Partially correct 40 ms 2340 KB Output isn't correct - L* = 0
28 Partially correct 39 ms 2412 KB Output isn't correct - L* = 0
29 Partially correct 33 ms 2360 KB Output isn't correct - L* = 0
30 Partially correct 32 ms 2188 KB Output isn't correct - L* = 0
31 Partially correct 33 ms 2272 KB Output isn't correct - L* = 0
32 Partially correct 31 ms 2412 KB Output isn't correct - L* = 0
33 Partially correct 33 ms 2340 KB Output isn't correct - L* = 0
34 Partially correct 30 ms 2208 KB Output isn't correct - L* = 0
35 Partially correct 35 ms 2228 KB Output isn't correct - L* = 0
36 Partially correct 32 ms 2336 KB Output isn't correct - L* = 0
37 Partially correct 34 ms 2424 KB Output isn't correct - L* = 0
38 Partially correct 35 ms 2356 KB Output isn't correct - L* = 0
39 Partially correct 32 ms 2232 KB Output isn't correct - L* = 0
40 Partially correct 36 ms 2308 KB Output isn't correct - L* = 0