Submission #243094

#TimeUsernameProblemLanguageResultExecution timeMemory
243094osaaateiasavtnlBroken Device (JOI17_broken_device)C++14
85 / 100
58 ms3328 KiB
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
 
#include "Annalib.h"
 
void Anna( int N, long long X, int K, int P[] ){
    vector <int> tri;
    while (X) {
        tri.app(X%3);
        X /= 3;        
    }
 
    reverse(all(tri));
 
    vector <bool> used(N);
    for (int i = 0; i < K; ++i)
        used[P[i]] = 1;
 
    /*
    cout << "tri : ";
    for (auto e : tri)
        cout << e << ' ';
    cout << endl;
    */
 
    int i = 0, ptr = 0;
    while (i + 1 < N) {
        if (ptr < tri.size() && (!used[i] || !((tri[ptr]+1)&1)) && (!used[i+1] || !(((tri[ptr]+1) >> 1) & 1))) {
            int x = tri[ptr++]+1;
            Set(i, x & 1);
            Set(i + 1, (x >> 1) & 1);
        }   
        else {
            Set(i, 0);
            Set(i + 1, 0);
        }   
        i += 2;
    }   
}
#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
 
#include "Brunolib.h"
 
long long Bruno( int N, int A[] ){
    ll ans = 0;
    for (int i = 0; i < N; i += 2) {
        int add = A[i] + (A[i+1]<<1);
        if (add) {
            --add;
            ans = ans * 3 + add;
        }   
    }
    return ans;
}

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:38:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (ptr < tri.size() && (!used[i] || !((tri[ptr]+1)&1)) && (!used[i+1] || !(((tri[ptr]+1) >> 1) & 1))) {
             ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...