답안 #1053504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053504 2024-08-11T12:40:28 Z Zicrus 레지스터 (IOI21_registers) C++17
46 / 100
1 ms 604 KB
#include <bits/stdc++.h>
#include "registers.h"
using namespace std;
 
typedef long long ll;
 
vector<bool> num(ll num) {
    vector<bool> res(2000);
    for (int i = 0; i < 2000; i++) {
        ll numBit = min(i, (int)(sizeof(ll)*4)-1);
        res[i] = (num >> numBit) & 1;
    }
    return res;
}
 
void getMin(int x, int y) {
    append_not(98, y);
    append_add(98, 98, 99);
    append_add(98, x, 98);
    append_right(98, 98, 10);
    append_and(x, x, 98);
    append_not(98, 98);
    append_and(y, y, 98);
    append_or(x, x, y);
}
 
void getMinMax(int x, int y) {
    append_not(98, y);
    append_add(98, 98, 99);
    append_add(98, x, 98);
    append_right(98, 98, 11);
    append_and(x+20, x, 98);
    append_and(y+40, y, 98);
    append_not(98, 98);
    append_and(y+20, y, 98);
    append_and(x+40, x, 98);
    append_or(x, x+20, y+20);
    append_or(y, x+40, y+40);
}
 
void construct_instructions(int s, int n, int k, int q) {
    if (s == 0) {
        append_store(97, num((1 << k) - 1));
        append_store(99, num(1));
        ll shift = n*k-k;
        append_right(1, 0, shift);
        shift -= k;
        while (shift > 0) {
            append_right(2, 0, shift);
            append_and(2, 2, 97);
            getMin(1, 2);
            shift -= k;
        }
        append_and(0, 0, 97);
        getMin(0, 1);
    }
    else {
        append_store(99, num((1 << k) - 1));
        for (int i = 0; i < n-1; i++) {
            append_right(i+1, i, k);
            append_and(i, i, 99);
        }
        for (int i = 0; i < n; i++) append_print(i);
        append_store(99, num(1));
        for (int j = 0; j < n; j++) {
            for (int i = n-2; i >= 0; i--) {
                getMinMax(i, i+1);
            }
        }
        for (int i = 0; i < n; i++) append_print(i);
        for (int i = n-1; i > 0; i--) {
            append_left(i, i, k);
            append_or(i-1, i-1, i);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Wrong answer detected in grader
4 Halted 0 ms 0 KB -