답안 #598354

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598354 2022-07-18T07:10:54 Z wiwiho 레지스터 (IOI21_registers) C++17
58 / 100
1 ms 212 KB
#include "registers.h"

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define ef(a) emplace_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define tomax(a, b) ((a) = max((a), (b)))
#define tomin(a, b) ((a) = min((a), (b)))
#define topos(a) ((a) = (((a) % MOD + MOD) % MOD))
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

ll ifloor(ll a, ll b){
    if(b < 0) a *= -1, b *= -1;
    if(a < 0) return (a - b + 1) / b;
    else return a / b;
}

ll iceil(ll a, ll b){
    if(b < 0) a *= -1, b *= -1;
    if(a > 0) return (a + b - 1) / b;
    else return a / b;
}

const int B = 2000;
int s, n, k, q;

void solve0_round(int r){
    append_right(1, 0, (1 << r) * k);
    append_xor(2, 0, 1);
    if(r == 0) append_and(2, 2, 90);
    
    append_print(0);
    append_print(1);
    append_print(2);

    if(k == 1){
        append_move(3, 2);
    }
    for(int i = 1; i < k; i *= 2){
        if(i == 1){
            append_right(80, 2, i * 2 >= k ? k - i : i);
            append_or(3, 2, 80);
        }
        else{
            append_right(80, 3, i * 2 >= k ? k - i : i);
            append_or(3, 3, 80);
        }
        append_print(3);
    }
    
    append_print(3);
    append_add(3, 3, 91);
    append_print(3);
    append_right(3, 3, 1);
    append_print(3);

    append_and(4, 0, 3);
    if(r == 0) append_and(4, 4, 90);

    append_add(5, 4, 90);
    
    append_and(6, 5, 92);
    append_right(7, 6, k - 1);

    append_add(8, 5, 7);

    append_or(9, 8, 4);

    append_and(10, 9, 2);

    for(int i = 0; i <= 10; i++) append_print(i);
    
    append_xor(0, 0, 10);
    
    append_print(0);
}

void solve0(){
    
    /*
        0: S = A
        1: B
        2: A xor B
        3: highbit of 2
        4: A and (3)
        5: (4) + 0000 | 1111 | 0000 | 1111
        6: (5) & 0000 | 1000 | 0000 | 1000
        7: (6) >> (k-1)
        8: (5) + (7)
        9: (8) or (4) // done
        10: (9) and (2)
        ans: A ^ (10)


        90: 0000 | 1111 | 0000 | 1111
        91: 0000 | 0001 | 0000 | 0001
        92: 0000 | 1000 | 0000 | 1000
        
        80: temp

    */
    
    int tn = 1;
    while(tn < n) tn *= 2;
    vector<bool> tmp(B);
    for(int i = n * k; i < tn * k; i++) tmp[i] = true;
    if(tn != n){
        append_store(1, tmp);
        append_or(0, 0, 1);
    }

    fill(iter(tmp), false);
    for(int i = 0; i < tn * k; i++){
        if(i / k % 2 == 0) tmp[i] = true;
    }
    append_store(90, tmp);

    fill(iter(tmp), false);
    for(int i = 0; i < tn; i++){
        if(i % 2 == 0) tmp[i * k] = 1;
    }
    append_store(91, tmp);
    append_left(92, 91, k - 1);

    for(int i = 0; tn > 1; i++, tn /= 2){
        if(i == 1) append_and(0, 0, 90);
        solve0_round(i);
    }

}

void solve1(){

}

void construct_instructions(int _s, int _n, int _k, int _q){
    s = _s, n = _n, k = _k, q = _q;
    
    if(s == 0) solve0();
    else solve1();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -