Submission #1049554

# Submission time Handle Problem Language Result Execution time Memory
1049554 2024-08-08T22:41:39 Z vjudge1 Bit Shift Registers (IOI21_registers) C++17
46 / 100
3 ms 860 KB
#include "registers.h"
#include<bits/stdc++.h>
using namespace std;
#define DO int K=i_dont_need.front();i_dont_need.pop();i_have_added.push(K);
int CCC;
const int B=2000;
queue<int> i_dont_need,i_have_added;
int AD_move(int x) {
    DO
    append_move(K,x);
    return K;
}
int AD_store(vector<bool> v){
    DO
    append_store(K,v);
    return K;
}
int AD_and(int x, int y){
    DO
    append_and(K,x,y);
    return K;
}
int AD_or(int x, int y){
    DO
    append_or(K,x,y);
    return K;
}
int AD_xor(int x, int y){
    DO
    append_xor(K,x,y);
    return K;
}
int AD_not(int x){
    DO
    append_not(K,x);
    return K;
}
int AD_left(int x, int s){
    DO
    append_left(K,x,s);
    return K;
}
int AD_right(int x, int s){
    DO
    append_right(K,x,s);
    return K;
}
int AD_add(int x, int y){
    DO
    append_add(K,x,y);
    return K;
}
int AD_neg(int reg){
    vector<bool>V(B);
    V[0]=1;
    return AD_add(AD_not(reg),AD_store(V));
}
void add_comparison(int a,int b){
    while(i_have_added.size())i_have_added.pop();
    int K=AD_xor(a,b);
    int UHH=AD_and(K,AD_add(AD_right(AD_not(AD_add(b,AD_neg(a))),B-1),AD_store(vector<bool>(B,1))));
    append_xor(a,a,UHH);
    append_xor(b,b,UHH);
}
void CCONV() {
    while(i_have_added.size())
        i_dont_need.push(i_have_added.front()),   
        i_have_added.pop();
}
void meerge(int sz,int k,int reg){
    if(sz==1)return;
    int sz1=sz/2,sz2=sz-sz1;
    int oth=AD_right(reg,k*sz1);
    append_left(reg,reg,B-k*sz1);
    append_right(reg,reg,B-k*sz1);
    meerge(sz1,k,reg);
    meerge(sz2,k,oth);
    add_comparison(reg,oth);
    i_have_added.push(oth);
    CCONV();
}
void construct_instructions(int s, int n, int k, int q) {
    for(int i=1;i<100;i++)
        i_dont_need.push(i);
    if(!s) {
        meerge(n,k,0);
    } else {
        for(int i=1;i<n;i++) {
            AD_right(i-1,k);
            append_left(i-1,i-1,B-k);
            append_right(i-1,i-1,B-k);
        }
        for(int i=1;i<n;i++)
            for(int j=0;j<n-i;j++) 
                add_comparison(j,j+1),CCONV();
        for(int i=1;i<n;i++)
            append_left(i,i,i*k),
            append_or(0,0,i);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 344 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 2 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -