답안 #1078421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078421 2024-08-27T17:02:06 Z oscar1f Broken Device (JOI17_broken_device) C++17
43 / 100
27 ms 2732 KB
#include<bits/stdc++.h>
#include "Annalib.h"
using namespace std;
using ll=long long;

static const ll TAILLE_MAX=150+5;
static bool estCache[TAILLE_MAX];
static ll nbVal;

static pair<bool,vector<ll>> calc(vector<ll> listeBit) {
    vector<ll> ans;
    ll pos=0;
    while (pos<nbVal) {
        if (!listeBit.empty() and !estCache[pos] and pos<nbVal-1 and (!estCache[pos+1] or listeBit.back()==0)) {
            ans.push_back(1);
            ans.push_back(listeBit.back());
            //cout<<1<<listeBit.back();
            listeBit.pop_back();
            pos+=2;
        }
        else {
            ans.push_back(0);
            //cout<<0;
            pos++;
        }
    }
    if (listeBit.empty()) {
        return {true,ans};
    }
    else {
        return {false,ans};
    }
} 

static void envoi(vector<ll> v) {
    for (int i=0;i<nbVal;i++) {
        Set(i,v[i]);
    }
}

void Anna(int N,ll X,int K,int P[]) {
    nbVal=N;
    ll obj=X;
    ll nbCache=K;
    for (ll i=0;i<nbVal;i++) {
        estCache[i]=false;
    }
    for (ll i=0;i<nbCache;i++) {
        estCache[P[i]]=true;
    }
    vector<ll> listeBit;
    while (obj>0) {
        listeBit.push_back(obj%2);
        obj/=2;
    }
    /*for (ll i:listeBit) {
        cout<<i;
    }
    cout<<endl;*/
    auto bonSens=calc(listeBit);
    if (bonSens.first) {
        envoi(bonSens.second);
    }
    else {
        for (ll i=0;i<(ll)listeBit.size();i++) {
            listeBit[i]=1-listeBit[i];
        } 
        envoi(calc(listeBit).second);
    }
    //cout<<endl;
}
#include<bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
using ll=long long;

ll Bruno(int N,int A[]) {
    ll nbVal=N,pos=0,rep=0;
    vector<ll> recu;
    while (pos<nbVal) {
        if (A[pos]==1) {
            recu.push_back(A[pos+1]);
            pos+=2;
        }
        else {
            pos++;
        }
    }
    if (recu.empty()) {
        return rep;
    }
    if (recu[0]==0) {
        for (ll i:recu) {
            rep*=2;
            rep+=1-i;
        }
    }
    else {
        for (ll i:recu) {
            rep*=2;
            rep+=i;
        }
    }
    //cout<<"!"<<rep<<endl;
    return rep;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 26 ms 2396 KB Output is partially correct - L* = 17
2 Partially correct 22 ms 2476 KB Output is partially correct - L* = 20
3 Partially correct 20 ms 2396 KB Output is partially correct - L* = 19
4 Partially correct 22 ms 2488 KB Output is partially correct - L* = 17
5 Partially correct 20 ms 2648 KB Output is partially correct - L* = 17
6 Partially correct 20 ms 2392 KB Output is partially correct - L* = 21
7 Partially correct 20 ms 2396 KB Output is partially correct - L* = 18
8 Partially correct 24 ms 2612 KB Output is partially correct - L* = 18
9 Partially correct 22 ms 2476 KB Output is partially correct - L* = 18
10 Partially correct 20 ms 2396 KB Output is partially correct - L* = 16
11 Partially correct 22 ms 2640 KB Output is partially correct - L* = 19
12 Partially correct 22 ms 2368 KB Output is partially correct - L* = 22
13 Partially correct 20 ms 2584 KB Output is partially correct - L* = 18
14 Partially correct 20 ms 2480 KB Output is partially correct - L* = 18
15 Partially correct 20 ms 2396 KB Output is partially correct - L* = 16
16 Partially correct 20 ms 2396 KB Output is partially correct - L* = 19
17 Partially correct 25 ms 2396 KB Output is partially correct - L* = 22
18 Partially correct 20 ms 2392 KB Output is partially correct - L* = 17
19 Partially correct 22 ms 2528 KB Output is partially correct - L* = 18
20 Partially correct 22 ms 2476 KB Output is partially correct - L* = 18
21 Partially correct 20 ms 2392 KB Output is partially correct - L* = 17
22 Partially correct 25 ms 2396 KB Output is partially correct - L* = 17
23 Partially correct 20 ms 2396 KB Output is partially correct - L* = 18
24 Partially correct 23 ms 2480 KB Output is partially correct - L* = 17
25 Partially correct 27 ms 2732 KB Output is partially correct - L* = 21
26 Partially correct 26 ms 2372 KB Output is partially correct - L* = 16
27 Partially correct 26 ms 2456 KB Output is partially correct - L* = 18
28 Partially correct 20 ms 2372 KB Output is partially correct - L* = 19
29 Partially correct 20 ms 2388 KB Output is partially correct - L* = 16
30 Partially correct 22 ms 2404 KB Output is partially correct - L* = 22
31 Partially correct 20 ms 2400 KB Output is partially correct - L* = 17
32 Partially correct 22 ms 2392 KB Output is partially correct - L* = 18
33 Partially correct 20 ms 2608 KB Output is partially correct - L* = 18
34 Partially correct 23 ms 2600 KB Output is partially correct - L* = 19
35 Partially correct 20 ms 2396 KB Output is partially correct - L* = 16
36 Partially correct 22 ms 2392 KB Output is partially correct - L* = 20
37 Partially correct 20 ms 2592 KB Output is partially correct - L* = 16
38 Partially correct 22 ms 2608 KB Output is partially correct - L* = 18
39 Partially correct 23 ms 2372 KB Output is partially correct - L* = 17
40 Partially correct 22 ms 2400 KB Output is partially correct - L* = 17