답안 #1067416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067416 2024-08-20T16:47:05 Z c2zi6 레지스터 (IOI21_registers) C++17
33 / 100
1 ms 604 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "registers.h"

const int B = 2000;
const int M = 100;
int k;

const int INT_ONE = 90;
const int BOOL_TRUE = 91;
const int BOOL_FALSE = 92;
const int K_ONES = 93;
/* REGISTERS [90, 98] ARE RESERVED FOR CONSTANTS */

void add_constants() {
    vector<bool> ret;
    ret = vector<bool>(B, 0);
    ret[0] = 1;
    append_store(INT_ONE, ret);
    ret = vector<bool>(B, 1);
    append_store(BOOL_TRUE, ret);
    ret = vector<bool>(B, 0);
    append_store(BOOL_FALSE, ret);
    ret = vector<bool>(B, 0);
    rep(i, k) ret[i] = 1;
    append_store(K_ONES, ret);
}

/* 2 operations */
void append_neg(int res, int reg1) {
    append_not(res, reg1);
    append_add(res, res, INT_ONE);
}

/* 3 operations */
void append_sub(int res, int reg1, int reg2) {
    append_neg(80, reg2);
    append_add(res, reg1, 80);
}

/* 2 operations */
void append_sign(int res, int reg1) {
    /* true if reg1 >= 0 */
    append_right(80, reg1, B-1);
    append_add(res, 80, BOOL_TRUE);
}

/* 5 operations */
void append_ge(int res, int reg1, int reg2) {
    append_sub(80, reg1, reg2);
    append_sign(res, 80);
}

/* 5 operations */
void append_le(int res, int reg1, int reg2) {
    append_sub(80, reg2, reg1);
    append_sign(res, 80);
}

/* 9 operations */
void append_min(int res, int reg1, int reg2) {
    append_le(80, reg1, reg2);
    append_not(81, 80);
    append_and(82, reg1, 80);
    append_and(83, reg2, 81);
    append_or(res, 82, 83);
}

void construct_instructions(int s, int n, int k_arg, int q) {k = k_arg;
    add_constants();

    append_and(2, 0, K_ONES);
    append_right(0, 0, k);
    rep(i, n-1) {
        append_and(1, 0, K_ONES);
        append_right(0, 0, k);
        append_min(2, 2, 1);
    }
    append_move(0, 2);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -