Submission #1078608

# Submission time Handle Problem Language Result Execution time Memory
1078608 2024-08-27T22:23:31 Z oscar1f Broken Device (JOI17_broken_device) C++17
100 / 100
34 ms 2864 KB
#include<bits/stdc++.h>
#include "Annalib.h"
using namespace std;
using ll=long long;

static const ll TAILLE_MAX=150+5,NB_HASARD=(ll)(1000*1000*1000+9)*(ll)(1000*1000*1000+7);
static bool estCache[TAILLE_MAX];
static ll nbVal,numBloc,pos;
static vector<ll> ans,listeTrois;
static vector<vector<ll>> corres={{1,2,3},{3,1,2},{2,3,1}};

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

static void ajout() {
    ans.push_back((corres[(NB_HASARD/numBloc)%3][listeTrois.back()])/2);
    ans.push_back((corres[(NB_HASARD/numBloc)%3][listeTrois.back()])%2);
    numBloc++;
    listeTrois.pop_back();
    pos+=2;
}

static void passe() {
    ans.push_back(0);
    ans.push_back(0);
    numBloc+=2;
    pos+=2;
}

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;
    }
    listeTrois.clear();
    while (obj>0) {
        listeTrois.push_back(obj%3);
        obj/=3;
    }
    ans.clear();
    pos=0;
    numBloc=1;
    int nbGagne=0;
    while (pos<nbVal) {
        if (!listeTrois.empty() and (!estCache[pos] or (corres[(NB_HASARD/numBloc)%3][listeTrois.back()])/2==0) 
                                and (!estCache[pos+1] or (corres[(NB_HASARD/numBloc)%3][listeTrois.back()])%2==0)) {
            if (estCache[pos] or estCache[pos+1]) {
                nbGagne++;
            }
            ajout();
        }
        else {
            passe();
        }
    }
    //cout<<nbGagne<<" ";
    envoi(ans);
    //cout<<endl;
}
#include<bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
using ll=long long;

static const ll NB_HASARD=(ll)(1000*1000*1000+9)*(ll)(1000*1000*1000+7);
static vector<vector<ll>> corres{{0,1,2},{1,2,0},{2,0,1}};

ll Bruno(int N,int A[]) {
    ll nbVal=N,rep=0,suiv,numBloc=1;
    vector<ll> recu;
    for (int i=0;i<nbVal;i+=2) {
        suiv=2*A[i]+A[i+1]-1;
        if (suiv>=0) {
            rep*=3;
            rep+=corres[(NB_HASARD/numBloc)%3][suiv];
            numBloc++;
        }
        else {
            numBloc+=2;
        }
    }
    return rep;
}
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2396 KB Output is correct - L* = 40
2 Correct 24 ms 2372 KB Output is correct - L* = 40
3 Correct 26 ms 2476 KB Output is correct - L* = 40
4 Correct 20 ms 2392 KB Output is correct - L* = 40
5 Correct 25 ms 2604 KB Output is correct - L* = 40
6 Correct 22 ms 2396 KB Output is correct - L* = 40
7 Correct 22 ms 2488 KB Output is correct - L* = 40
8 Correct 23 ms 2404 KB Output is correct - L* = 40
9 Correct 20 ms 2480 KB Output is correct - L* = 40
10 Correct 22 ms 2396 KB Output is correct - L* = 40
11 Correct 22 ms 2396 KB Output is correct - L* = 40
12 Correct 22 ms 2864 KB Output is correct - L* = 40
13 Correct 22 ms 2396 KB Output is correct - L* = 40
14 Correct 22 ms 2480 KB Output is correct - L* = 40
15 Correct 23 ms 2740 KB Output is correct - L* = 40
16 Correct 20 ms 2392 KB Output is correct - L* = 40
17 Correct 20 ms 2432 KB Output is correct - L* = 40
18 Correct 26 ms 2400 KB Output is correct - L* = 40
19 Correct 20 ms 2476 KB Output is correct - L* = 40
20 Correct 22 ms 2392 KB Output is correct - L* = 40
21 Correct 23 ms 2392 KB Output is correct - L* = 40
22 Correct 27 ms 2448 KB Output is correct - L* = 40
23 Correct 23 ms 2372 KB Output is correct - L* = 40
24 Correct 22 ms 2372 KB Output is correct - L* = 40
25 Correct 27 ms 2396 KB Output is correct - L* = 40
26 Correct 20 ms 2372 KB Output is correct - L* = 40
27 Correct 20 ms 2460 KB Output is correct - L* = 40
28 Correct 20 ms 2656 KB Output is correct - L* = 40
29 Correct 20 ms 2648 KB Output is correct - L* = 40
30 Correct 20 ms 2392 KB Output is correct - L* = 40
31 Correct 23 ms 2396 KB Output is correct - L* = 40
32 Correct 22 ms 2388 KB Output is correct - L* = 40
33 Correct 20 ms 2396 KB Output is correct - L* = 40
34 Correct 20 ms 2396 KB Output is correct - L* = 40
35 Correct 22 ms 2396 KB Output is correct - L* = 40
36 Correct 20 ms 2392 KB Output is correct - L* = 40
37 Correct 20 ms 2392 KB Output is correct - L* = 40
38 Correct 22 ms 2396 KB Output is correct - L* = 40
39 Correct 23 ms 2380 KB Output is correct - L* = 40
40 Correct 23 ms 2480 KB Output is correct - L* = 40