Submission #903403

# Submission time Handle Problem Language Result Execution time Memory
903403 2024-01-11T07:32:49 Z abcvuitunggio Bit Shift Registers (IOI21_registers) C++17
71 / 100
1 ms 604 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
const int b=2000;
int k;
void minimize(){
    append_not(3,1);
    append_add(3,2,3);
    append_right(3,3,k);
    append_not(4,3);
    append_and(3,3,2);
    append_and(4,4,1);
    append_add(2,3,4);
}
void bubble(int i){
    append_move(2,i+5);
    append_move(1,i+6);
    minimize();
    append_add(1,i+5,i+6);
    append_move(i+5,2);
    append_not(2,2);
    append_add(1,1,2);
    append_add(i+6,1,98);
}
void construct_instructions(int s, int n, int k, int q){
    ::k=k;
    vector <bool> ve(b,0);
    for (int i=n*k;i<b;i++)
        ve[i]=1;
    append_store(97,ve);
    append_or(0,0,97);
    for (int i=0;i<b;i++)
        ve[i]=(i%(k*2)<k);
    append_store(96,ve);
    int x=1;
    while (x<n)
        x*=2;
    n=x;
    if (!s){
        int d=k;
        while (x>1){
            append_right(1,0,d);
            append_and(0,0,96);
            append_and(1,1,96);
            append_not(2,1);
            append_add(2,0,2);
            append_right(2,2,k);
            append_not(3,2);
            append_and(2,2,0);
            append_and(3,3,1);
            append_or(0,2,3);
            x/=2;
            d*=2;
        }
        return;
    }
    vector <bool> v(2000,0);
    v[0]=1;
    append_store(98,v);
    for (int i=0;i<n;i++){
        append_move(i+5,0);
        append_left(i+5,i+5,b-k*(i+1));
        append_right(i+5,i+5,b-k);
    }
    for (int i=n-1;i;i--)
        for (int j=0;j<i;j++)
            bubble(j);
    append_move(0,99);
    for (int i=0;i<n;i++){
        append_left(i+5,i+5,k*i);
        append_add(0,0,i+5);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 352 KB Wrong answer detected in grader
4 Halted 0 ms 0 KB -