답안 #511129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
511129 2022-01-15T07:59:48 Z cig32 레지스터 (IOI21_registers) C++17
58 / 100
1 ms 460 KB
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;

void construct_instructions(int s, int n, int k, int q) {
    const int b = 2000;
	//Subtask group 1: 21 points
    if(s == 0 && n == 2 && k <= 2) {
        if(k == 1) {
            append_right(1, 0, 1);
            vector<bool> oh(b);
            oh[0] = 1;
            append_store(2, oh);
            append_and(0, 0, 2);
            append_and(0, 0, 1);
            return;
        }
        else {
            append_right(1, 0, 2);
            vector<bool> oh(b);
            oh[0] = oh[1] = 1;
            append_store(2, oh);
            append_and(0, 0, 2);
            for(int i=0; i<3; i++) {
                append_move(2, 1);
                for(int j=0; j<k; j++) {
                    int tar = (i == 2 && j == k-1 ? 0 : 2);
                    append_add(tar, 0, 2);
                    append_right(tar, tar, 1);
                }
                if(i < 2) append_move(0, 2);
            }
            return;
        }
    }
    //Subtask group 2: 12 points
    if(s == 0 && q == 4000) {
        vector<bool> init2(b);
        for(int i=0; i<b; i++) init2[i] = 1;
        vector<bool> init(b);
        for(int i=0; i<k; i++) init[i] = 1;
        append_store(4, init2);
        append_store(5, init);
        append_move(1, 0);
        append_and(1, 1, 5);
        append_right(0, 0, k);
        for(int i=1; i<n; i++) {
            append_move(2, 0);
            append_and(2, 2, 5);
            append_right(0, 0, k);
            append_not(3, 2);
            append_add(3, 3, 1);
            append_right(3, 3, 1999);
            append_add(3, 3, 4);
            append_and(2, 2, 3);
            append_not(3, 3);
            append_and(1, 1, 3);
            append_add(1, 1, 2);
        }
        append_move(0, 1);
        return;
    }
    vector<bool> w(b);
    for(int i=0; i<b; i++) w[i] = 0;
    for(int i=0; i<n; i++) w[(i+1)*k - 1] = 1;
    append_store(2, w);
    vector<bool> v(b);
    v[0] = 1;
    for(int i=1; i<n*k; i++) v[i] = 0;
    for(int i=n*k; i<b; i++) v[i] = 1;
    append_store(4, v);       //r[4] = - (2^nk - 1) forever
    vector<bool> c(b);
    c[0] = 1;
    append_store(6, c); //r[6] = 1 forever
    for(int i=k-1; i>=0; i--) {
        append_and(1, 0, 2);
        if(k-1 > i) append_left(1, 1, k-1 - i);
        append_right(3, 1, k-1);
        append_not(3, 3);
        append_add(5, 1, 3);
        append_add(5, 5, 6);
        append_or(1, 1, 5);
        append_add(7, 1, 4);
        append_right(7, 7, 1999);
        append_xor(7, 7, 6);
        append_left(8, 7, i);
        append_add(9, 9, 8);
        if(i > 0) {
            append_add(1, 1, 7);
            append_right(2, 2, 1);
            append_or(0, 0, 1);
        }
    }
    append_move(0, 9);
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Incorrect sorting
2 Halted 0 ms 0 KB -