제출 #1223915

#제출 시각아이디문제언어결과실행 시간메모리
1223915hengliaoBit Shift Registers (IOI21_registers)C++20
23 / 100
2 ms756 KiB
#include "registers.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>

typedef int ll;

namespace{
    const int LOG=4;
    const int diff=100;
    const ll B=2000;
    const ll m=100;
}

void construct_instructions(int s, int n, int k, int q) {
    ll cnt=0;
    vector<bool> v1(B), v2(B), v3(B);
    for(ll i=0;i<k;i++){
        v1[i]=1;
        v3[i]=1;
    }
    for(ll i=diff;i<diff+k;i++){
        v2[i]=1;
        v3[i]=1;
    }

    auto check=[&](){
        cnt++;
        if(cnt>=q-1) assert(false);
    };

    append_store(m-2, v1);
    append_store(m-1, v2);
    append_store(m-3, v3);
    cnt+=3;
    vector<vector<bool>> v(n, vector<bool>(B, 1));
    for(ll i=0;i<n;i++){
        for(ll j=i*k;j<(i+1)*k;j++){
            v[i][j]=0;
        }
    }
    auto find_small=[&](int a){
        append_right(3, a, diff);
        check();
        append_and(4, a, 3);
        check();
        append_and(4, 4, m-2);
        check();
        append_left(5, 4, diff);
        check();
        append_or(4, 5, 4);
        check();
        append_xor(6, 4, a);
        check();
        // append_print(6);
        // check();
        append_not(7, 6);
        check();
        // append_print(7);
        // check();
        for(int i=0;i<LOG;i++){
            append_right(8, 7, (1<<i));
            check();
            append_and(7, 7, 8);
            check();
        }
        append_right(9, 7, diff);
        check();
        append_and(9, m-2, 9);
        check();
        append_and(7, 7, m-2);
        check();
        append_left(7, 7, diff);
        check();
        append_or(9, 7, 9);
        check();
        append_and(6, 6, 9);
        check();
        for(int i=0;i<LOG;i++){
            append_right(8, 6, (1<<i));
            check();
            append_or(6, 6, 8);
            check();
        }
        append_or(a, a, 6);
        check();
        append_right(3, a, diff);
        check();
        append_and(4, a, 3);
        check();
        append_and(4, 4, m-2);
        check();
        return 4;
    };  
    append_move(1, 0);
    check();
    append_and(1, 1, m-2);
    check();
    for(ll i=0;i<n;i++){
        for(ll j=n-2;j>=i;j--){
            append_right(2, 0, k*(j+1));
            check();
            // append_print(2);
            // check();
            append_left(2, 2, diff);
            check();
            append_and(2, 2, m-1);
            check();
            append_right(3, 0, k*j);
            check();
            append_and(3, 3, m-2);
            check();
            append_or(2, 3, 2);
            check();
            append_move(90, 2);
            check();
            ll re=find_small(2);

            check();
            append_move(1, re);
            
            check();
            append_not(90, 90);
            check();
            append_and(90, 90, m-3);
            check();
            re=find_small(90);
            check();
            append_move(2, re);
            
            check();
            append_not(2, 2);
            append_and(2, 2, m-2);
            append_print(1);
            append_print(2);
            check();
            append_left(1, 1, k*j);
            check();
            append_left(2, 2, k*(j+1));
            check();
            append_store(m-4, v[j]);
            check();
            append_and(0, 0, m-4);
            check();
            append_store(m-4, v[j+1]);
            check();
            append_and(0, 0, m-4);
            check();
            append_or(0, 0, 1);
            check();
            append_or(0, 0, 2);
            check();
        }
    }                               
    // append_move(0, 1);
    // cout<<"cnt: "<<cnt<<'\n';
    return;                                 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...